Skip to content

Commit

Permalink
add servicemonitor
Browse files Browse the repository at this point in the history
Signed-off-by: walnuts1018 <[email protected]>
  • Loading branch information
walnuts1018 committed Feb 25, 2025
1 parent 0a516bc commit 7ee47e8
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions k8s/apps/loki/servicemonitor.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
local helmname = (import 'helm.jsonnet').spec.source.helm.releaseName;

{
apiVersion: 'monitoring.coreos.com/v1',
kind: 'ServiceMonitor',
metadata: {
name: 'loki',
namespace: 'loki',
labels: (import '../../components/labels.libsonnet') + { appname: (import 'app.json5').name },
},
spec: {
selector: {
matchLabels: {
'app.kubernetes.io/name': 'loki',
'app.kubernetes.io/instance': helmname,
},
matchExpressions: [
{
key: 'prometheus.io/service-monitor',
operator: 'NotIn',
values: ['false'],
},
],
},
endpoints: [
{
port: 'http-metrics',
path: '/metrics',
interval: '15s',
relabelings: [
{
sourceLabels: ['job'],
action: 'replace',
replacement: 'default/$1',
targetLabel: 'job',
},
{
action: 'replace',
replcaement: helmname,
targetLabel: 'cluster',
},
],
scheme: 'http',
},
],
},
}

0 comments on commit 7ee47e8

Please sign in to comment.