Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upCreate "promlint" tool for linting metric types, names, and labels #1953
Comments
This comment has been minimized.
This comment has been minimized.
|
Apologies, looks like an issue was already opened about a similar idea: #1902. Should have searched more. :) Leaving open for discussion on some of the proposed ideas anyway. Feel free to close if you'd like to move discussion elsewhere. |
This comment has been minimized.
This comment has been minimized.
|
This is a great idea, I've been thinking about such tools a few times, although more in the context of rules files. Issue #1902 was meant to check for invalid metric outputs (e.g. for scenarios in which no client_library is being used), so an extra ticket make sense for the linter use case. In addition to just linting /metrics, a rule linter would be even more helpful for me, as I guide other developers more often through the creation of rules than creation of new metrics. Possible lint checks:
Similar to the existing Using reserved label names should be a check error and not a linter warning. |
This comment has been minimized.
This comment has been minimized.
|
More lint checks:
|
This comment has been minimized.
This comment has been minimized.
|
For someone implementing this, the |
This comment has been minimized.
This comment has been minimized.
|
@grobie perhaps:
I spent some time thinking about this. It would be nice if the parser passed through the comments, that would let you override the linter in a comment before a rule/alert. I was leaning toward promtool check-rules -lint (maybe with -lint.ignore, -lint.error , -lint.warn to let you turn linters on/off, and say which could cause a check-rules to fail) |
This comment has been minimized.
This comment has been minimized.
|
What would be examples for overriding the linter? On Sun, Sep 18, 2016, 06:25 Tristan Colgate-McFarlane <
|
This comment has been minimized.
This comment has been minimized.
|
@grobie overrides could be used to mark known breaches of the established policy, to stop things causing build failures for instance. e.g. perhaps I have some rules (I do), that don't conform to labels:metric:funcs (e.g. we allow a kpi: prefix to force non job: aggregations into our long term storage). It's nice to be able to fail a build on a lint error, but if you are going to have that option, you should probably provide the ability to override it. |
This comment has been minimized.
This comment has been minimized.
|
Started messing around with this tonight.
I'd be happy to add a few basic checks and clean it up for submission. I think starting small with lint checks makes sense, since we can always add more over time. Would love to hear others' thoughts. |
brian-brazil
added
the
kind/enhancement
label
Oct 26, 2016
mdlayher
referenced this issue
Apr 10, 2017
Merged
Initial commit of 'promtool check-metrics', promlint package #2605
juliusv
closed this
in
#2605
Apr 13, 2017
This comment has been minimized.
This comment has been minimized.
lock
bot
commented
Mar 23, 2019
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
mdlayher commentedSep 7, 2016
I think it would be an excellent idea to create a linting tool that ensures best practices are used when creating metrics. This could become a new binary,
promlint, or perhaps an addition topromtoolaspromtool lint.In order to make it useful for more than one language, I think it would be a good idea to directly inspect the metrics notation typically output by prometheus and its exporters, such as:
The tool could look for issues such as:
_totalwith a metric that is not a counterquantilelabel with a counter metric_millisecondssuffix instead of_secondsAs an example, the tool's output could look something like:
I think it would also make sense to allow the tool to ingest metrics in a variety of ways for maximum flexibility. Some trivial examples:
I'm happy to negotiate semantics and such, but I think the general idea is sound. This is a tool I would certainly use when working with Prometheus on my own projects. In addition, since it isn't tied to any specific programming language, it would become immediately useful to a wide audience with varying programming backgrounds.
If I'm on the right track, I'd be happy to work on a prototype, and eventually submit a pull request to merge it into the project.
Thanks for your time! Looking forward to hearing your thoughts!