1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/jsonnet/lens/custom-prometheus.jsonnet
elvis chan 6c0bcc403b
fix jsonnet error with kube-prometheus >= v0.8 (#5687)
* fix jsonnet error with kube-prometheus > v0.8

kubelet ServiceMonitor moved to kubernetesControlPlane starting from v0.8

Signed-off-by: elvis chan <78713260+elvischan-crypto@users.noreply.github.com>

* Add not in custom-prometheuus.md about jsonnet version

Signed-off-by: Sebastian Malton <sebastian@malton.name>

Signed-off-by: elvis chan <78713260+elvischan-crypto@users.noreply.github.com>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Co-authored-by: Sebastian Malton <sebastian@malton.name>
2022-10-19 10:17:07 -04:00

49 lines
1.3 KiB
Plaintext

{
// Add Lens metric relabelings for custom prometheus instances installed with kube-prometheus
// https://github.com/lensapp/lens/blob/master/troubleshooting/custom-prometheus.md
nodeExporter+:: {
serviceMonitor+: {
spec+: {
endpoints: std.map(function(endpoint)
if endpoint.port == "https" then
endpoint {
relabelings+: [
{
action: 'replace',
regex: '(.*)',
replacement: '$1',
sourceLabels: ['__meta_kubernetes_pod_node_name'],
targetLabel: 'kubernetes_node',
}
],
}
else
endpoint,
super.endpoints
),
},
},
},
kubernetesControlPlane+:: {
serviceMonitorKubelet+: {
spec+: {
endpoints: std.map(function(endpoint)
if endpoint.port == "https-metrics" then
endpoint {
metricRelabelings+: [
{
action: 'replace',
sourceLabels: ['node'],
targetLabel: 'instance',
},
],
}
else
endpoint,
super.endpoints
),
},
},
},
}