1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Add jsonnet definitions for kube-prometheus

Signed-off-by: Christian Beneke <christian.beneke@traderepublic.com>
This commit is contained in:
Christian Beneke 2020-04-01 13:08:29 +02:00
parent eab8231f92
commit ab8fc9833a
2 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,40 @@
{
// 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
),
},
},
},
prometheus+:: {
serviceMonitorKubelet+: {
spec+: {
metricRelabelings+: [
{
action: 'replace',
sourceLabels: ['node'],
targetLabel: 'instance',
},
],
},
},
},
}

View File

@ -4,6 +4,8 @@ When using custom prometheus with Lens app, Lens expects certain things for prom
## kube-prometheus ## kube-prometheus
### Manual
1. To see node metrics properly, please add 1. To see node metrics properly, please add
``` ```
@ -27,6 +29,29 @@ metricRelabelings:
targetLabel: instance targetLabel: instance
``` ```
### Jsonnet
The required label replacements are bundled in [jsonnet/custom-prometheus](../jsonnet/custom-prometheus.jsonnet). To install it copy the file or use
[Jsonnet Bundler](https://github.com/jsonnet-bundler/jsonnet-bundler):
```
jb install github.com/lensapp/lens/jsonnet
```
And include it into your definitions. Using the [example](https://github.com/coreos/kube-prometheus#compiling) of kube-prometheus, e.g.:
```
local kp =
(import 'kube-prometheus/kube-prometheus.libsonnet') +
(import 'lens/custom-prometheus.jsonnet') +
{
_config+:: {
namespace: 'monitoring',
},
};
...
```
## Helm chart ## Helm chart
1. To see cpu metrics properly, please set value of `server.global.scrape_timeout` less than 1 minute, for example 1. To see cpu metrics properly, please set value of `server.global.scrape_timeout` less than 1 minute, for example