Skip to content

Commit c7a4d1e

Browse files
committed
Port of linera-io#2994 - Send Prometheus metrics to Grafana Cloud
We're migrating our internal validators to send data to Grafana Cloud. Starting with the local setup. This was useful to test the required changes that we'll likely need for the actual internal validator setup. We probably won't want to send metrics to Grafana Cloud from local runs all the time (specially for cost reasons), so this is disabled by default. Grafana Cloud credentials are stored in a secret within GCP's Secret Manager. Since Grafana Cloud will be for our internal validators, then I figured storing the secret on GCP made sense. Ran locally with `linera net up --kubernetes`, and saw the metrics in our Grafana Cloud instance: ![Screenshot 2024-12-02 at 11.37.04.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/HlciHFAoHZW62zn13apJ/4b46c8bc-a5d3-4aad-9e3f-151cf44be947.png) If we want to start sending metrics to Grafana Cloud from our devnet/testnet, then: - These changes should be backported to the latest `devnet` branch - These changes should be backported to the latest `testnet` branch, then
1 parent 2320441 commit c7a4d1e

File tree

3 files changed

+48
-17
lines changed

3 files changed

+48
-17
lines changed

kubernetes/linera-validator/helmfile.yaml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
environments:
2+
default:
3+
values:
4+
- writeToGrafanaCloud: {{ env "LINERA_WRITE_TO_GRAFANA_CLOUD" | default "false" }}
5+
validatorLabel: {{ env "LINERA_VALIDATOR_LABEL" | default (printf "local-%s" (env "USER")) }}
6+
7+
---
8+
19
repositories:
210
- name: scylla
311
url: https://scylla-operator-charts.storage.googleapis.com/stable
@@ -16,22 +24,15 @@ releases:
1624
needs:
1725
- scylla/scylla
1826
values:
19-
- {{ env "LINERA_HELMFILE_VALUES_LINERA_CORE" | default "values-local.yaml" }}
27+
{{ if .Values.writeToGrafanaCloud -}}
28+
- grafanaCloudUsername: {{ fetchSecretValue (env "LINERA_GRAFANA_CLOUD_USERNAME_SECRET") | quote }}
29+
grafanaCloudAPIToken: {{ fetchSecretValue (env "LINERA_GRAFANA_CLOUD_API_TOKEN_SECRET") | quote }}
30+
{{- end }}
31+
- writeToGrafanaCloud: {{ .Values.writeToGrafanaCloud }}
32+
- {{ env "LINERA_HELMFILE_VALUES_LINERA_CORE" | default "values-local.yaml.gotmpl" }}
2033
set:
2134
- name: installCRDs
2235
value: "true"
23-
- name: validator.serverConfig
24-
value: {{ env "LINERA_HELMFILE_SET_SERVER_CONFIG" | default "working/server_1.json" }}
25-
- name: validator.genesisConfig
26-
value: {{ env "LINERA_HELMFILE_SET_GENESIS_CONFIG" | default "working/genesis.json" }}
27-
- name: numShards
28-
value: {{ env "LINERA_HELMFILE_SET_NUM_SHARDS" | default 10 }}
29-
- name: lineraImage
30-
value: {{ env "LINERA_HELMFILE_LINERA_IMAGE" | default "linera:latest" }}
31-
- name: staticIpGcpName
32-
value: {{ env "LINERA_HELMFILE_STATIC_IP_GCP_NAME" | default "" }}
33-
- name: validatorDomainName
34-
value: {{ env "LINERA_HELMFILE_VALIDATOR_DOMAIN_NAME" | default "" }}
3536
- name: scylla
3637
version: v1.13.0
3738
namespace: scylla
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{- if .Values.writeToGrafanaCloud }}
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: grafana-cloud-auth-secret
6+
type: kubernetes.io/basic-auth
7+
stringData:
8+
username: {{ .Values.grafanaCloudUsername | quote }}
9+
password: {{ .Values.grafanaCloudAPIToken | quote }}
10+
{{- end }}

kubernetes/linera-validator/values-local.yaml renamed to kubernetes/linera-validator/values-local.yaml.gotmpl

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Values for charts linera-validator for local validators.
22

33
# Linera
4-
lineraImage: "" # Is set by helmfile.
4+
lineraImage: {{ env "LINERA_HELMFILE_LINERA_IMAGE" | default "linera:latest" }}
55
lineraImagePullPolicy: Never
66
logLevel: "debug"
77
proxyPort: 19100
88
metricsPort: 21100
9-
numShards: 10
9+
numShards: {{ env "LINERA_HELMFILE_SET_NUM_SHARDS" | default 10 }}
1010

1111
# Loki
1212
loki-stack:
@@ -40,6 +40,26 @@ kube-prometheus-stack:
4040
- grafana-piechart-panel
4141
prometheus:
4242
prometheusSpec:
43+
{{- if .Values.writeToGrafanaCloud }}
44+
scrapeInterval: 90s
45+
remoteWrite:
46+
- url: https://prometheus-prod-13-prod-us-east-0.grafana.net/api/prom/push
47+
basicAuth:
48+
username:
49+
name: grafana-cloud-auth-secret
50+
key: username
51+
password:
52+
name: grafana-cloud-auth-secret
53+
key: password
54+
writeRelabelConfigs:
55+
- sourceLabels: [__name__]
56+
regex: (apiextensions|apiserver|csi|kube|kubelet|kubernetes|node|prober|prometheus|rest|storage|volume|etcd|net|grafana|authentication|code|workqueue|cluster|go|alertmanager|authorization|namespace|scrape|up|field|registered|process|scylla).+
57+
action: drop
58+
- regex: endpoint|instance|namespace|pod|prometheus|prometheus_replica|service|name|resource|id
59+
action: labeldrop
60+
externalLabels:
61+
validator: {{ .Values.validatorLabel }}
62+
{{- end }}
4363
retention: 2d
4464
retentionSize: 1GB
4565
storageSpec:
@@ -101,5 +121,5 @@ environment: "kind"
101121

102122
# Validator
103123
validator:
104-
serverConfig: "" # Is set by helmfile.
105-
genesisConfig: "" # Is set by helmfile.
124+
serverConfig: {{ env "LINERA_HELMFILE_SET_SERVER_CONFIG" | default "working/server_1.json" }}
125+
genesisConfig: {{ env "LINERA_HELMFILE_SET_GENESIS_CONFIG" | default "working/genesis.json" }}

0 commit comments

Comments
 (0)