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

GREEDY field templates for the graphite parser #789

Closed
wants to merge 1 commit into from
Closed

GREEDY field templates for the graphite parser #789

wants to merge 1 commit into from

Conversation

chrusty
Copy link
Contributor

@chrusty chrusty commented Mar 3, 2016

No description provided.

@@ -94,6 +94,13 @@ func TestTemplateApply(t *testing.T) {
measurement: "cpu.load",
tags: map[string]string{"zone": "us-west"},
},
{
test: "conjoined fields",
Copy link
Contributor

Choose a reason for hiding this comment

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

here you should test that the correct fields get applied.

ie, this should test that measurement=="cpu.util" and field=="idle.percent" (feel free to make a separate test function for testing field templates)

@sparrc
Copy link
Contributor

sparrc commented Mar 3, 2016

@chrusty can this also support specifying multiple fields?, ie, host.measurement.measurement.field.field

@chrusty
Copy link
Contributor Author

chrusty commented Mar 5, 2016

@sparrc OK, I've added a test for the field-name. Regarding the multiple-fields question, no at the moment it doesn't, but I could add it.

I found this example in another issue (#39):

cpu.usage,host=server01,region=us-west:idle=10.0,user=50.0,system=40.0|g
=> statsd_cpu_usage_gauge,host='server01',region='us-west' idle=10,user=50,system=50

I'm skiing this week, but i'll see if i get a bad-weather day to take a look.

@sparrc
Copy link
Contributor

sparrc commented Mar 18, 2016

@chrusty any updates?

@chrusty
Copy link
Contributor Author

chrusty commented Mar 19, 2016

@sparrc So the initial part of the PR seems to work fine, but I'm struggling with the "multiple fields" thing... is there an accepted way of sending multi-value metrics (multi-field) with StatsD, or would people just send several metrics with different field names instead?

It looks like you can send several metrics for a measurement, but I believe that StatsD would treat those as different metrics for the same measurement (not different fields for the same metric).

@sparrc
Copy link
Contributor

sparrc commented Mar 21, 2016

@chrusty that's not what I had in mind exactly, I was thinking a template like this:

host.measurement.measurement.field.field

would translate graphite to this:

localhost.cpu.usage.idle.percent 99
=> cpu_usage,host=localhost idle_percent=99

_, _, _, err = p.ApplyTemplate("current.users.logged_in")
if err == nil {
t.Errorf("Parser.ApplyTemplate unexpected result. got %s, exp %s", err,
"'field' can only be used once in each template: current.users.logged_in")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to remove this constraint to allow the new feature.

@chrusty
Copy link
Contributor Author

chrusty commented Mar 21, 2016

@sparrc I think this does what you want. Sorry, I'd assumed that the feature you'd asked for was much more complex!

@sparrc sparrc closed this in 20b4e8c Mar 21, 2016
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