-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[Fix #190] Add httpjson tags support #275
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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,69 @@ | ||
# HTTP JSON Plugin | ||
|
||
The httpjson plugin can collect data from remote URLs which respond with JSON. Then it flattens JSON and finds all numeric values, treating them as floats. | ||
|
||
For example, if you have a service called _mycollector_, which has HTTP endpoint for gathering stats http://my.service.com/_stats: | ||
|
||
``` | ||
[[httpjson.services]] | ||
name = "mycollector" | ||
|
||
servers = [ | ||
"http://my.service.com/_stats" | ||
] | ||
|
||
# HTTP method to use (case-sensitive) | ||
method = "GET" | ||
``` | ||
|
||
The name is used as a prefix for the measurements. | ||
|
||
The `method` specifies HTTP method to use for requests. | ||
|
||
You can specify which keys from server response should be considered as tags: | ||
|
||
``` | ||
[[httpjson.services]] | ||
... | ||
|
||
tagKeys = [ | ||
"role", | ||
"version" | ||
] | ||
``` | ||
|
||
**NOTE**: tag values should be strings. | ||
|
||
You can also specify additional request parameters for the service: | ||
|
||
``` | ||
[[httpjson.services]] | ||
... | ||
|
||
[httpjson.services.parameters] | ||
event_type = "cpu_spike" | ||
threshold = "0.75" | ||
|
||
``` | ||
|
||
|
||
# Sample | ||
|
||
Let's say that we have a service named "mycollector", which responds with: | ||
```json | ||
{ | ||
"a": 0.5, | ||
"b": { | ||
"c": "some text", | ||
"d": 0.1, | ||
"e": 5 | ||
} | ||
} | ||
``` | ||
|
||
The collected metrics will be: | ||
``` | ||
httpjson_mycollector_a value=0.5 | ||
httpjson_mycollector_b_d value=0.1 | ||
httpjson_mycollector_b_e value=5 | ||
``` |
This file contains 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
This file contains 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
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.
Won't this break the entire plugin if there is a non-string key in the top-level of the JSON?
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.
Yes, response can contain JSON array. We should have a test case for this)
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.
Hm, this plugin wasn't aware of array JSON. I think this should go to another PR (along with support for string values, do you know why the plugin supports only floats, btw?).
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.
@palkan supporting strings could become very complicated, there tends to be a lot of metadata in JSON that users probably don't want. Also storing strings as InfluxDB values has bad compression and isn't very useful.