-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Integration] Add a Twemproxy integration #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f88db0c
[Integration] Add a Twemproxy integration
tmichelet 4f4f3fe
[Twemproxy] Update manifest with more soon-to-be mandatory fields
tmichelet d73d224
[Twemproxy] Add support info to manifest
tmichelet bf62e39
[Twemproxy] Add a max agent version
tmichelet d9ff5f3
update twemproxy readme and template readme
technovangelist 784be56
update to the install command for the check
technovangelist 9d23967
Merge pull request #8 from DataDog/mattw/twemproxy-readme
tmichelet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,38 @@ | ||
| # dd-official-check | ||
| some prototyping | ||
| About this readme document: The README.md file should be formatted in valid markdown. All of the main sections listed below should be H1's. They should be the only H1's in the document otherwise they will not be used. | ||
|
|
||
| # Overview | ||
| **Absolutely Required.** | ||
|
|
||
| The overview section is required and should be a paragraph or two with some bullets of what is interesting about this integration. For example, the following comes from the Docker integration. | ||
|
|
||
| Get metrics from Docker in real time to: | ||
|
|
||
| * Visualize your containers' performance. | ||
| * Correlate the performance of containers with the applications running inside. | ||
|
|
||
| There are three ways to setup the Docker integration: install the agent on the host, on a single priviledged container, and on each individual container. | ||
|
|
||
| # Installation | ||
| **Required with some exceptions** | ||
|
|
||
| The installation section should cover anything that needs to be installed on the agent host. For instance, in the Docker installation section you learn about installing the agent into a container. If there is nothing to install on the agent host, this section can be left out. To be a complete integration, either an installation section or a configuration section must be included. | ||
|
|
||
| # Configuration | ||
| **Required with some exceptions** | ||
|
|
||
| The configuration section should cover anything that you can configure in the Datadog interface or the agent configuration files. In almost every case this section should be included since there is almost always something to configure. To be a complete integration, either an installation section or a configuration section must be included. | ||
|
|
||
| # Validation | ||
| **Required** | ||
|
|
||
| The validation section should include instructions on how to validate that the integration is successfully working. | ||
|
|
||
| # Troubleshooting | ||
| **Optional** | ||
|
|
||
| The troubleshooting section should include anything that answers a question a user might have about the integration. If there is a question that comes up in support about the integration, it should be added here. | ||
|
|
||
| # Compatibility | ||
| **Required** | ||
|
|
||
| The compatibility section should include which versions this integration has been tested and validated on. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Overview | ||
|
|
||
| Get metrics from Twitter's twemproxy in real time to: | ||
|
|
||
| * Visualize client and server connectivity | ||
| * Correlate performance of the proxy to the Redis or Memcached server behind it | ||
|
|
||
| # Installation | ||
|
|
||
| Install the integration using `apt-get install dd-check-twemproxy` | ||
|
|
||
| # Configuration | ||
|
|
||
| Edit the `twemproxy.yaml` file to point to your server and port | ||
|
|
||
| # Validation | ||
|
|
||
| When you run `datadog-agent info` you should see something like the following: | ||
|
|
||
| Checks | ||
| ====== | ||
|
|
||
| twemproxy | ||
| --------- | ||
| - instance #0 [OK] | ||
| - Collected 17 metrics, 0 events & 1 service check | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| # stdlib | ||
| import urllib2 | ||
|
|
||
| # 3rd party | ||
| import simplejson as json | ||
|
|
||
| # project | ||
| from checks import AgentCheck | ||
|
|
||
| GLOBAL_STATS = set([ | ||
| 'curr_connections', | ||
| 'total_connections' | ||
| ]) | ||
|
|
||
| POOL_STATS = set([ | ||
| 'client_eof', | ||
| 'client_err', | ||
| 'client_connections', | ||
| 'server_ejects', | ||
| 'forward_error' | ||
| ]) | ||
|
|
||
| SERVER_STATS = set([ | ||
| 'in_queue', | ||
| 'out_queue', | ||
| 'server_connections', | ||
| 'server_err', | ||
| 'server_timedout', | ||
| 'server_eof' | ||
| ]) | ||
|
|
||
|
|
||
| class Twemproxy(AgentCheck): | ||
| """Tracks twemproxy metrics via the stats monitoring port | ||
|
|
||
| Connects to twemproxy via the configured stats port. | ||
| See https://github.com/twitter/twemproxy#observability | ||
|
|
||
| $ curl localhost:22222 | ||
| { | ||
| "service":"nutcracker", | ||
| "source":"i-deadbeef", | ||
| "version":"0.4.1", | ||
| "uptime":4018, | ||
| "timestamp":1446677875, | ||
| "total_connections":244, | ||
| "curr_connections":23, | ||
| "poolA": { | ||
| # pool stats | ||
| "client_eof":221, | ||
| "client_err":0, | ||
| "client_connections":15, | ||
| "server_ejects":0, | ||
| "forward_error":0, | ||
| "fragments":0, | ||
| "serverA": { | ||
| # server stats | ||
| "server_eof":0, | ||
| "server_err":0, | ||
| "server_timedout":0, | ||
| "server_connections":1, | ||
| "server_ejected_at":0, | ||
| "requests":46873, | ||
| "request_bytes":127685831, | ||
| "responses":46872, | ||
| "response_bytes":194030, | ||
| "in_queue":1, | ||
| "in_queue_bytes":190, | ||
| "out_queue":0, | ||
| "out_queue_bytes":0 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| """ | ||
| def check(self, instance): | ||
| if 'url' not in instance: | ||
| raise Exception('Twemproxy instance missing "url" value.') | ||
| tags = instance.get('tags', []) | ||
|
|
||
| response = self._get_data(instance) | ||
| self.log.debug(u"Nginx status `response`: {0}".format(response)) | ||
|
|
||
| metrics = self.parse_json(response, tags) | ||
| for row in metrics: | ||
| try: | ||
| name, value, tags = row | ||
| self.gauge(name, value, tags) | ||
| except Exception, e: | ||
| self.log.error( | ||
| u'Could not submit metric: %s: %s', | ||
| (repr(row), str(e)) | ||
| ) | ||
|
|
||
| def _get_data(self, instance): | ||
| url = instance.get('url') | ||
|
|
||
| self.log.debug(u"Querying URL: {0}".format(url)) | ||
| response = urllib2.urlopen(url) | ||
| return response.read() | ||
|
|
||
| @classmethod | ||
| def parse_json(cls, raw, tags=None): | ||
| if tags is None: | ||
| tags = [] | ||
| parsed = json.loads(raw) | ||
| metric_base = 'twemproxy' | ||
| output = [] | ||
|
|
||
| for key, val in parsed.iteritems(): | ||
| if isinstance(val, dict): | ||
| # server pool | ||
| pool_tags = tags + ['pool:%s' % key] | ||
| for pool_key, pool_val in val.iteritems(): | ||
| if isinstance(pool_val, dict): | ||
| # server | ||
| server_tags = pool_tags + ['server:%s' % pool_key] | ||
| for stat in SERVER_STATS: | ||
| metric_name = '%s.%s' % (metric_base, stat) | ||
| output.append( | ||
| (metric_name, pool_val.get(stat), server_tags) | ||
| ) | ||
|
|
||
| elif pool_key in POOL_STATS: | ||
| metric_name = '%s.%s' % (metric_base, pool_key) | ||
| output.append((metric_name, pool_val, pool_tags)) | ||
|
|
||
| elif key in GLOBAL_STATS: | ||
| metric_name = '%s.%s' % (metric_base, key) | ||
| output.append((metric_name, val, tags)) | ||
|
|
||
| return output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| init_config: | ||
|
|
||
| instances: | ||
| - url: http://localhost:22222 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "manifest_version": "0.1.0", | ||
| "name": "twemproxy", | ||
| "version": "0.1.0", | ||
| "min_agent_version": "5.6.3", | ||
| "max_agent_version": "6.0.0", | ||
| "support": "contrib" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| simplejson |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| metric_name,metric_type,interval,unit_name,per_unit_name,description,orientation,integration,short_name | ||
| twemproxy.client_connections,guage,,,The number of client connections,0,twemproxy,client connections | ||
| twemproxy.client_eof,guage,,,something,0,twemproxy,client eof | ||
| twemproxy.client_err,guage,,,something,0,twemproxy,client err | ||
| twemproxy.forward_error,guage,,,something,0,twemproxy,forward error | ||
| twemproxy.in_queue,guage,,,something,0,twemproxy,in queue | ||
| twemproxy.out_queue,guage,,,something,0,twemproxy,out queue | ||
| twemproxy.server_connections,guage,,,something,0,twemproxy,server connections | ||
| twemproxy.server_ejects,guage,,,something,0,twemproxy,server ejects | ||
| twemproxy.server_eof,guage,,,something,0,twemproxy,server eof | ||
| twemproxy.server_err,guage,,,something,0,twemproxy,server errors | ||
| twemproxy.server_timedout,guage,,,something,0,twemproxy,server timed out |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"maintainer": "help@datadoghq.com"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"support": "core"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"short_description": "dasa"