Skip to content

Commit

Permalink
feat: Add Loki to Helm chart deployment (#436)
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 authored Jan 9, 2025
1 parent 0685fc6 commit 4a68f1d
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/helm-charts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
if: steps.list-changed.outputs.changed == 'true'
run: |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add grafana https://grafana.github.io/helm-charts
helm dependency update charts/hedera-block-node
- name: Run chart-testing (install)
Expand Down
8 changes: 8 additions & 0 deletions charts/hedera-block-node/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ dependencies:
condition: kubepromstack.enabled
version: "51.2.0" # Use the latest stable version
repository: "https://prometheus-community.github.io/helm-charts"
- name: "loki"
condition: loki.enabled
repository: "https://grafana.github.io/helm-charts"
version: "^2.15.2"
- name: "promtail"
condition: promtail.enabled
repository: "https://grafana.github.io/helm-charts"
version: "^6.7.4"
11 changes: 11 additions & 0 deletions charts/hedera-block-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ kubepromstack:
enabled: false
```
### Enable Loki + Promtail
By default the stack includes chart dependencies for a loki + promtail stack, to collect logs from the Hedera Block Node and the K8 cluster.
If you prefer to use your own loki+promtail stack, you can disable the stack by setting the following values:
```yaml
loki:
enabled: false

promtail:
enabled: false
```
## Using
Follow the `NOTES` instructions after installing the chart to perform `port-forward` to the Hedera Block Node and be able to use it.

Expand Down
18 changes: 18 additions & 0 deletions charts/hedera-block-node/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,21 @@ Usage: {{ include "hedera-block-node.app.version" . }}
{{- define "hedera-block-node.appVersion" -}}
{{- default .Chart.AppVersion .Values.blockNode.version -}}
{{- end -}}

{{/*
The service name to connect to Loki. Defaults to the same logic as "loki.fullname"
*/}}
{{- define "loki.serviceName" -}}
{{- if .Values.loki.serviceName -}}
{{- .Values.loki.serviceName -}}
{{- else if .Values.loki.fullnameOverride -}}
{{- .Values.loki.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default "loki" .Values.loki.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
9 changes: 9 additions & 0 deletions charts/hedera-block-node/templates/grafana-datasource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,14 @@ data:
editable: true
jsonData:
timeInterval: "15s"
{{- if .Values.loki.enabled }}
- name: Loki
type: loki
url: http://{{ .Release.Name }}-loki:3100
access: proxy
isDefault: false
editable: true
{{- end }}
{{- end }}
40 changes: 40 additions & 0 deletions charts/hedera-block-node/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,43 @@ kubepromstack:

nodeExporter:
enabled: true

loki:
enabled: true
isDefault: true
url: http://{{(include "loki.serviceName" .)}}:{{ .Values.loki.service.port }}
readinessProbe:
httpGet:
path: /ready
port: http-metrics
initialDelaySeconds: 45
livenessProbe:
httpGet:
path: /ready
port: http-metrics
initialDelaySeconds: 45
datasource:
jsonData: "{}"
uid: ""

promtail:
enabled: true
config:
logLevel: info
serverPort: 3101
clients:
- url: http://{{ .Release.Name }}-loki:3100/loki/api/v1/push
snippets:
pipelineStages:
- docker:
label_fields:
stream: stream
- multiline:
# A regex that identifies the start of a new log entry
firstline: '^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'
# Maximum wait time for more lines before sending the collected log upstream
max_wait_time: 3s
separator: ''
- replace:
expression: '(\n){2,}'
replace: ''

0 comments on commit 4a68f1d

Please sign in to comment.