Skip to content

Commit

Permalink
Simplify regexp's
Browse files Browse the repository at this point in the history
This is mostly to remove redundant anchoring (as it makes people
believe that Prometheus's regexp's aren't anchored by default, which
will backfire badly at some point), but it also removes useless
grouping (again to avoid confusion).

Signed-off-by: beorn7 <[email protected]>
  • Loading branch information
beorn7 committed Oct 26, 2019
1 parent 51105f6 commit b838d74
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/clients/promtail/scraping.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ value or transformed to a final external label, such as `__job__`.
* Drop the target if a label (`__service__` in the example) is empty:
```yaml
- action: drop
regex: ^$
regex: ''
source_labels:
- __service__
```
Expand Down
18 changes: 9 additions & 9 deletions production/helm/promtail/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ data:
- __meta_kubernetes_pod_node_name
target_label: __host__
- action: drop
regex: ^$
regex: ''
source_labels:
- __service__
- action: labelmap
Expand Down Expand Up @@ -75,7 +75,7 @@ data:
- __meta_kubernetes_pod_node_name
target_label: __host__
- action: drop
regex: ^$
regex: ''
source_labels:
- __service__
- action: labelmap
Expand Down Expand Up @@ -118,7 +118,7 @@ data:
- __meta_kubernetes_pod_label_name
- __meta_kubernetes_pod_label_app
- action: drop
regex: ^([0-9a-z-.]+)(-[0-9a-f]{8,10})$
regex: '[0-9a-z-.]+-[0-9a-f]{8,10}'
source_labels:
- __meta_kubernetes_pod_controller_name
- source_labels:
Expand All @@ -128,7 +128,7 @@ data:
- __meta_kubernetes_pod_node_name
target_label: __host__
- action: drop
regex: ^$
regex: ''
source_labels:
- __service__
- action: labelmap
Expand Down Expand Up @@ -171,19 +171,19 @@ data:
- __meta_kubernetes_pod_label_name
- __meta_kubernetes_pod_label_app
- action: keep
regex: ^([0-9a-z-.]+)(-[0-9a-f]{8,10})$
regex: '[0-9a-z-.]+-[0-9a-f]{8,10}'
source_labels:
- __meta_kubernetes_pod_controller_name
- action: replace
regex: ^([0-9a-z-.]+)(-[0-9a-f]{8,10})$
regex: '([0-9a-z-.]+)-[0-9a-f]{8,10}'
source_labels:
- __meta_kubernetes_pod_controller_name
target_label: __service__
- source_labels:
- __meta_kubernetes_pod_node_name
target_label: __host__
- action: drop
regex: ^$
regex: ''
source_labels:
- __service__
- action: labelmap
Expand Down Expand Up @@ -220,7 +220,7 @@ data:
- role: pod
relabel_configs:
- action: drop
regex: ^$
regex: ''
source_labels:
- __meta_kubernetes_pod_annotation_kubernetes_io_config_mirror
- action: replace
Expand All @@ -231,7 +231,7 @@ data:
- __meta_kubernetes_pod_node_name
target_label: __host__
- action: drop
regex: ^$
regex: ''
source_labels:
- __service__
- action: labelmap
Expand Down
12 changes: 6 additions & 6 deletions production/ksonnet/promtail/scrape_config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ config + {
{
source_labels: ['__service__'],
action: 'drop',
regex: '^$',
regex: '',
},

// Include all the other labels on the pod.
Expand Down Expand Up @@ -122,7 +122,7 @@ config + {
{
source_labels: ['__meta_kubernetes_pod_controller_name'],
action: 'drop',
regex: '^([0-9a-z-.]+)(-[0-9a-f]{8,10})$',
regex: '[0-9a-z-.]+-[0-9a-f]{8,10}',
},

// Use controller name as __service__.
Expand All @@ -149,15 +149,15 @@ config + {
// Drop pods not from an indirect controller. eg StatefulSets, DaemonSets
{
source_labels: ['__meta_kubernetes_pod_controller_name'],
regex: '^([0-9a-z-.]+)(-[0-9a-f]{8,10})$',
regex: '[0-9a-z-.]+-[0-9a-f]{8,10}',
action: 'keep',
},

// put the indirect controller name into a temp label.
// Put the indirect controller name into a temp label.
{
source_labels: ['__meta_kubernetes_pod_controller_name'],
action: 'replace',
regex: '^([0-9a-z-.]+)(-[0-9a-f]{8,10})$',
regex: '([0-9a-z-.]+)-[0-9a-f]{8,10}',
target_label: '__service__',
},
]
Expand All @@ -171,7 +171,7 @@ config + {
{
action: 'drop',
source_labels: ['__meta_kubernetes_pod_annotation_kubernetes_io_config_mirror'],
regex: '^$',
regex: '',
},

// Static control plane pods usually have a component label that identifies them
Expand Down

0 comments on commit b838d74

Please sign in to comment.