flant / shell-operator

Shell-operator is a tool for running event-driven scripts in a Kubernetes cluster
https://flant.github.io/shell-operator/
Apache License 2.0
2.44k stars 214 forks source link

Missing custom metrics #557

Closed szb640 closed 11 months ago

szb640 commented 11 months ago

Expected behavior (what you expected to happen): Metrics appended via $METRICS_PATH should appear in prometheus results.

Actual behavior (what actually happened): From v1.4.2+, metrics are added successfully (confirmed by logs), however they are not returned by prometheus.

Steps to reproduce:

  1. Add hook and deploy
  2. Inside the container run curl 127.0.0.1:9115/metrics

Environment:

Anything else we should know?: This is working as expected in ghcr.io/flant/shell-operator:v1.4.1, but seems broken in v1.4.2 and v1.4.3.

Additional information for debugging (if necessary):

Hook script
#!/usr/bin/env bash

source /shell_lib.sh

function __config__() {
    cat <> ${METRICS_PATH}
}

hook::run $@
Logs
{"level":"info","msg":"Create metric counter my_counter","operator.component":"metricStorage","time":"2023-11-20T00:00:00Z"}
{"binding":"","event":"onStartup","hook":"startup.sh","level":"info","msg":"Hook executed successfully","queue":"","task":"HookRun","time":"2023-11-21T14:38:12Z"}
szb640 commented 11 months ago

I've found #549 introduced a breaking change in how metrics are reported, they are no longer exposed on /metrics path but on /metrics/hooks.