Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Regex parse labels? #415

Open
wrouesnel opened this issue Jun 12, 2015 · 4 comments
Open

Regex parse labels? #415

wrouesnel opened this issue Jun 12, 2015 · 4 comments

Comments

@wrouesnel
Copy link

Is it possible (or could it be made possible) to format legend labels with regex's applied to the actual time series? Mostly so long instance-name's can be filtered down to the small chunk of relevant data for display.

i.e. server.domain.com:9100 => server

@grobie
Copy link
Contributor

grobie commented Jun 14, 2015

You can use one of the available filters promdash provides: hostname or the generic regex. Legend string example:

{{ instance | hostname }}

These should have been documented ages ago, you can follow prometheus/docs#57 for updates.

@wrouesnel
Copy link
Author

Trying out a few of those, they don't seem to work at the moment - i.e.
instance = "host.example.org:9100" with the filter {{ instance | hostname }} just yielded a blank entry.

And regex matching only seems to do simple string substitutions without punctuation - adding periods (.) at any point broke the parsing of the label.

@grobie
Copy link
Contributor

grobie commented Jun 14, 2015

Oh, you uncovered a compatibility problem with the new instance label. Prometheus >= 0.11.0 dropped the scheme and path from the values. I'm confused why it hasn't hit us (soundcloud) yet.

Anyway, the hostname filters should probably be changed to work with an hostname:port format as well. a.href rejects values without a scheme it seems.

I was able to replicate your observations around the regex filter. I was unable to execute the first test for regex. @stuartnelson3 any ideas why the test behavior seems to differ here?

PRs welcome as usual :D I might take a look tomorrow otherwise.

@stuartnelson3
Copy link
Collaborator

the issue with the regex filter lies in variable_interpolator.js. that whole file needs to be replaced.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants