-
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
Conversation
awesome, thank you @palkan! I see that you have another PR to fix the test issue too :-) Could you also write a short README for this plugin, and include the info you wrote above about tagging? You can use the exec plugin as an example. |
also, just to clarify, do these tag keys need to be in the top-level of the map? |
for _, tag := range service.Tags { | ||
switch v := jsonOut[tag].(type) { | ||
case string: | ||
tags[tag] = v |
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.
indentation, should all be tabs in Go
I like this, and I also opened #277 to allow for a more general |
@palkan one more thing: can you change the name |
@@ -61,6 +62,12 @@ var sampleConfig = ` | |||
# HTTP method to use (case-sensitive) | |||
method = "GET" | |||
|
|||
# List of tag names to extract from server response | |||
tags = [ |
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.
comment this by default
Tags should be in the top level of the map. Of course, we can look for tags in lower levels, but we have to consider prefixes here. One possible solution is to flatten JSON first, and provide tags names with prefixes, e.g.: # json
{
"key": 1,
"some": {
"key": 2
},
"none": {
"key": 3
},
} and config [httpjson]
tagKeys = [
"key",
"some_key"
]
will produce |
sorry for the delay @palkan, I'll get this merged this weekend 👍 |
Tags are extracted from JSON response according to the list of tags in config.
Example:
And resulting point will contain values
value: 123
and tagsrole: master build: 2015 server_name: ...
.