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 upSupport regex-less relabling #3117
Comments
This comment has been minimized.
This comment has been minimized.
|
The question I would ask is what does this allow that relabelling already doesn't? I've seen very few cases where such syntactic sugar would help, and having more than one way to do things is rarely a win for users. Particularly for something like relabelling. |
This comment has been minimized.
This comment has been minimized.
|
Heh, funny, we just ran into a limitation of relabel rules (as mentioned in #2545) which could be solved by interpolation of labels in other fields. This would make it possible to configure k8s discovery only with relabel rules. - action: keep
source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_ports] # comma separated list of ports for example
regex: "(^|,){{ __meta_kubernetes_pod_container_port_number }}($|,)"
- action: replace
source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
target_label: __address__
regex: '(.+?)(?::\d+)?;(\d+)'
replacement: $1:$2The second rule could then also be rewritten as follows, close to @discordianfish suggestion: - action: replace
target_label: __addess__
replacement: {{ __meta_kubernetes_pod_ip }}:{{ __meta_kubernetes_pod_container_port_number }} |
grobie
referenced this issue
Aug 25, 2017
Closed
Discover multiple (but not all) Ports in a Kubernetes Pod #2545
This comment has been minimized.
This comment has been minimized.
|
That's a bit of a different feature again, and you've yet to demonstrate that what you want to do isn't already possible with relabel rules. I note that the Go regex library does not support what's being requested here. |
This comment has been minimized.
This comment has been minimized.
|
My intention wasn't to support something that isn't possible yet. My goal would be to make Prometheus more accessible by making relabing more readable ultimately reducing support efforts and drive adoption. |
This comment has been minimized.
This comment has been minimized.
|
How often does this pattern come up? As I've said I believe replace actions that'd benefit from this are quite rare (e.g. there's none in the k8 example, and that's on the complex side as relabelling goes; nor does it help with the blackbox/snmp pattern). To add what is basically another templating language to Prometheus, I think we'd want something like this to be very common to balance against the complexity&confusion that an additional language and syntax would cause. |
This comment has been minimized.
This comment has been minimized.
wjoel
commented
Apr 12, 2018
|
Being able to do this, and similar things, has been requested over and over again.
Doing this is not possible with just Go regex. The pattern comes up very often. |
This comment has been minimized.
This comment has been minimized.
|
@wjoel That is unrelated to this issue. |
discordianfish commentedAug 25, 2017
Hi,
not feeling too strongly about it but definitely a nice to have which arguably would be less complex to manage as a a user than the regex we have right now. It think I never had an actual need for an regex.
We should support
action: replacewithout a regex, which would simply make all labels available in the replacement. This could be look like this:Alternatively we could keep source_labels and just map them 1:1 to position args in replacement:
Might need to be a new action though since the current behavior is different.
Feel free to close this if it seems out of scope but I believe it makes one of the most mind bending parts of the prometheus config much easier to understand.