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

Adopt statsd_exporter mapper #52

Merged
merged 4 commits into from
Aug 22, 2018
Merged

Conversation

travisgroth
Copy link
Contributor

@matthiasr

This is to address #37. Also would implicitly address #38, #40, #10, and #32 (I think?). There may be additional resolutions from #37 as well.

NB: I actually copied in and modified the statsd mapper and dependencies, as it sits in their main package and thus isn't importable. Tests not updated yet, though basic functionality seems fine in both glob and regex modes. The mapper interface is similar, so the changes in main.go were trivial.

Would like to take the project's temperature on approach/changes and would be happy to add in anything trivial while I have my attention on this.

@matthiasr
Copy link
Contributor

matthiasr commented Aug 12, 2018 via email

matthiasr pushed a commit to prometheus/statsd_exporter that referenced this pull request Aug 12, 2018
This allows the mapping logic and configuration format to be re-used by
the graphite exporter.

Enables prometheus/graphite_exporter#37, cf. prometheus/graphite_exporter#52 (comment)

Signed-off-by: Matthias Rampke <[email protected]>

add missing license header

Signed-off-by: Matthias Rampke <[email protected]>
matthiasr pushed a commit to prometheus/statsd_exporter that referenced this pull request Aug 12, 2018
This allows the mapping logic and configuration format to be re-used by
the graphite exporter.

Enables prometheus/graphite_exporter#37, cf. prometheus/graphite_exporter#52 (comment)

Signed-off-by: Matthias Rampke <[email protected]>
@matthiasr
Copy link
Contributor

@travisgroth please take a look: prometheus/statsd_exporter#140

@travisgroth
Copy link
Contributor Author

I'm not sure how valuable directly importing that mapper is but it would certainly be better if it was possible. To be honest, it might make sense to eventually consolidate the projects, or shift more to a mostly shared code base. Anyway, I'm on board with small steps here.

Can I propose continuing on this PR in parallel while taking care to honor the existing statsd_exporter mapper interface? I made no changes to the original code other than some trivial renaming. I'm open to depending on a (your?) fork instead, since that is now an option.

If statsd doesn't want to expose the mapper or the PR sits for a while, I don't want to have this change blocked, as I'd like to get the regex support in the near term. Once the statsd_exporter mapper PR is resolved we can trivially switch to directly consume it, if appropriate.

I can probably pick this up tomorrow evening if that all sounds good.

@matthiasr
Copy link
Contributor

matthiasr commented Aug 13, 2018 via email

@travisgroth
Copy link
Contributor Author

I'm maintainer for both projects
so I can do whatever is necessary to unblock doing this right.

Ah, did not realize. Great! Will check out the PR.

@travisgroth
Copy link
Contributor Author

Basic refactor done but I vendored your branch for the moment.

Would like to at least try to add a little testing around the processLine() method before calling this done. Should be able to do so later this week.

Copy link
Contributor

@matthiasr matthiasr left a comment

Choose a reason for hiding this comment

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

Looks good so far! I'm always in favor of tests. Can you also update the README and prepare a note about the breaking change in the changelog?

Does @bakins' config converter work for this?

main.go Outdated
if present {
name = labels["name"]
name = invalidMetricChars.ReplaceAllString(mapping.Name, "_")
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldit make sense to add a helper for this to the mapper package?

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 refactored that bit anyway (not pushed yet) and, as it turns out, it seems like something later in the data path cleans that up. I figured that out working on the unit test. So, there may already be a helper somewhere in the prom code that can be leveraged, but I haven't gone looking just yet.

@travisgroth
Copy link
Contributor Author

@matthiasr OK I think I'm done making code changes here unless you see something off. Please take a look over as I did have to make some updates in main to support testing.

Will work on readme/changelog.

Re: converter - you mean this, right? https://github.com/bakins/statsd-exporter-convert I'm not familiar with project history here but offhand it does look that way. Did they originally share that same parser? I will give it a cursory try and link over in the docs if it appears to work.

@matthiasr
Copy link
Contributor

Yes, historically the mappers were copies, but they diverged.

Copy link
Contributor

@matthiasr matthiasr left a comment

Choose a reason for hiding this comment

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

Looks good so far! Could you take a look at the build failures?

@@ -105,5 +117,5 @@
"revisionTime": "2017-07-27T04:22:29Z"
}
],
"rootPath": "github.com/prometheus/graphite_exporter"
"rootPath": "github.com/travisgroth/graphite_exporter"
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll need to change this back before it hits master … I think one way to be able to develop locally under a different name is to check out the exporter at github.com/prometheus/graphite_exporter and add your fork as an additional remote.

Copy link
Contributor Author

@travisgroth travisgroth Aug 20, 2018

Choose a reason for hiding this comment

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

I probably broke the vendor.json rootPath early on so let me fix that and repath.

Edit - nevermind. I was conflating a local error with the CI error. Looks like just me fumbling with govendor.

README.md Outdated
```
mappings:
- match: test.dispatcher.*.*.*
name: dispatcher_events_total
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the indentation here is off?

@matthiasr
Copy link
Contributor

I don't understand the last commit (247f94c) … IIRC as it stands the client library will refuse to serve these anyway. OTOH that's probably something we need to address (outside of this PR) so it's good to be able to parse them. Ok carry on 🦆

Please keep in mind that you need to put the sign-off on every commit before I can merge this.

@travisgroth
Copy link
Contributor Author

travisgroth commented Aug 21, 2018 via email

Copy link
Contributor

@matthiasr matthiasr left a comment

Choose a reason for hiding this comment

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

Ah that makes sense then! This looks good to me, is there anything else you want to do besides rebasing?

README.md Outdated
graphite metrics into labeled Prometheus metrics via YAML configuration file. This file shares syntax and logic with [statsd_exporter](https://github.com/prometheus/statsd_exporter). Please follow the statsd_exporter documentation for usage information. However, graphite_exporter does not support *all* parsing features at this time. Specific differences in functionality:

- timer_type is not supported. All metrics are assumed to be gauges as graphite does not distinguish.
- quantiles are not supported
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this implied by the first statement? what about histograms?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I suppose that is all implied by just saying "only gauges" right now. Good point.

@travisgroth
Copy link
Contributor Author

I think that's all the changes for me. Will try to put the rebase together this evening.

@matthiasr
Copy link
Contributor

Looks great, thank you for bearing with me and getting this through!

@matthiasr matthiasr merged commit 19f9a6f into prometheus:master Aug 22, 2018
@travisgroth
Copy link
Contributor Author

Not a problem. Glad to get this in!

@efficks efficks mentioned this pull request Feb 11, 2019
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