Skip to content
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
wants to merge 3 commits into from
Closed

[Fix #190] Add httpjson tags support #275

wants to merge 3 commits into from

Conversation

palkan
Copy link
Contributor

@palkan palkan commented Oct 16, 2015

Tags are extracted from JSON response according to the list of tags in config.

Example:

# config
[httpjson.services]
  tagKeys = [
    "role",
    "build"
  ]
# server response
{
  "value": 123,
  "role": "master",
  "build": "2015"
}

And resulting point will contain values value: 123 and tags role: master build: 2015 server_name: ....

@sparrc
Copy link
Contributor

sparrc commented Oct 16, 2015

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.

@sparrc
Copy link
Contributor

sparrc commented Oct 16, 2015

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
Copy link
Contributor

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

@sparrc
Copy link
Contributor

sparrc commented Oct 16, 2015

I like this, and I also opened #277 to allow for a more general tags key to be used to add ad-hoc tags.

@sparrc
Copy link
Contributor

sparrc commented Oct 16, 2015

@palkan one more thing: can you change the name tags to tagkeys so that it's more clear that we are referring to keys from the JSON that will be used as tags

@@ -61,6 +62,12 @@ var sampleConfig = `
# HTTP method to use (case-sensitive)
method = "GET"

# List of tag names to extract from server response
tags = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment this by default

@palkan
Copy link
Contributor Author

palkan commented Oct 19, 2015

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 httpjson_service,key=1,some_key=2 ....

@palkan
Copy link
Contributor Author

palkan commented Oct 23, 2015

@sparrc
We're waiting until we end up with something in #277?

@sparrc
Copy link
Contributor

sparrc commented Oct 23, 2015

sorry for the delay @palkan, I'll get this merged this weekend 👍

@sparrc sparrc closed this in cb951eb Oct 24, 2015
allenj pushed a commit to allenj/telegraf that referenced this pull request Nov 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants