Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbluth/f51063b1f86e6bb3934357cb658c232f to your computer and use it in GitHub Desktop.
Save cbluth/f51063b1f86e6bb3934357cb658c232f to your computer and use it in GitHub Desktop.
Prometheus relabelling to get rid of port number
============================================
============================================
============================================
This does what it should:
regex: (.+?)(:80)?
Also see https://golang.org/pkg/regexp/syntax/
============================================
============================================
============================================
This returns 'instance="XX"'
- targets:
- XX:80
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):80'
replacement: '${1}'
============================================
But auto-attached :80 does not go away and results in 'instance="XX:80"'
- targets:
- XX
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*):80'
replacement: '${1}'
============================================
Returns 'instance="XX"'
- targets:
- XX
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*)(:80)?'
replacement: '${1}'
============================================
Returns 'instance="XX:80"'
- targets:
- XX:80
relabel_configs:
- source_labels: [ __address__ ]
target_label: instance
regex: '(.*)(:80)?'
replacement: '${1}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment