sensu / sensu-processes-check

Sensu check that searches for certain running processes
MIT License
0 stars 6 forks source link

Add metrics output #5

Open jspaleta opened 2 years ago

jspaleta commented 2 years ago
calebhailey commented 2 years ago

I think we might need to bump the version in go.mod to 1.17... otherwise I was getting a compile error on UnixMilli

$ go build                                                                                                                      
# github.com/sensu/sensu-processes-check
./metrics.go:24:21: time.Now().UnixMilli undefined (type time.Time has no field or method UnixMilli)
$ go version
go version go1.16.3 linux/amd64
calebhailey commented 2 years ago

I think we should drop the hard-coded host.name tag. I know it's there for dashboard compat, but we should use output_metric_tags for that. We should try to keep any built-in tags as minimal as possible.

Same for the search_string tag. Although you couldn't add this tag via output_metric_tags when searching for multiple processes, it seems likely that it might often be the same as process.executable.name.

calebhailey commented 2 years ago

Encountered an error when configured with output_metrics_format: prometheus_text:

{
  "check": "process-monitoring",
  "component": "agent",
  "error": "unable to extract metric from check output",
  "level": "error",
  "msg": "text format parsing error in line 3: expected '=' after label name, found '.'",
  "namespace": "default",
  "time": "2022-05-12T01:07:02Z"
}

From the Prometheus docs:

Label names may contain ASCII letters, numbers, as well as underscores. They must match the regex [a-zA-Z_][a-zA-Z0-9_]*. Label names beginning with __ are reserved for internal use.

We'll need to change the following labels: