custom-metrics-generator
is generate prometheus metrics using custom resource definition.
You can output any metrics to http endpoints like a prometheus exporter.
public.ecr.aws/q1m5p9s1/custom-metrics-generator
(amd64 linux only)
$ IMG=<<your repository>>:<<tag>> make docker-build
See manifest/deploy
.
$ kustomize build manifests/deploy | kubectl apply -f -
-generate-metrics-bind-address string
Generated metrics endpoint addr. (default ":8082")
-generate-metrics-path string
Generated metrics path. (default "/metrics")
-interval-seconds int
interval seconds to fetch metrics (default 60)
-metrics-prefix string
set prefix for metrics name (default none)
-offset-seconds int
offset seconds to generate metrics (default 0)
-timezone string
set timezone (default "UTC")
Sample is in manifest/resource
.
Name | Type | Required | Description |
---|---|---|---|
spec.metricsName | string | Yes | Name of generated metrics. |
spec.offsetSeconds | int | No | Offset seconds to generate metrics (override flag setting) |
spec.timezone | string | No | Set timezone (override flag setting) |
spec.labels | map[string]string | No | Labels to be added to generated metrics. |
spec.metrics.start | string | Yes | Cron formatted schedule to start output metrics. |
spec.metrics.duration | duration | Yes | Duration to keep output metrics. |
spec.metrics.value | int | Yes | Value of output metrics. |
spec.metricsName
must match the regex [a-zA-Z_:][a-zA-Z0-9_:]*
.
Keys in spec.labels
must match the regex [a-zA-Z_][a-zA-Z0-9_]*
and cannot start with two or more _
.
See also prometheus docs.
If invalid character is used, it is replaced by _
.
spec.metrics
field is specified as array, so you can define more than one.
If multiple metrics have overlapping schedules, new schedule metrics will be used.
If you are using Argo CD, you can set argo-cd custom health check by adding below to configMap argocd-cm
.
For more information, https://argo-cd.readthedocs.io/en/stable/operator-manual/health/
resource.customizations.health.k8s.oder.com_MetricsSource: |
hs = {}
if obj.status ~= nil then
if obj.status.conditions ~= nil then
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" and condition.status == "False" then
hs.status = "Degraded"
hs.message = condition.message
return hs
end
if condition.type == "Ready" and condition.status == "True" then
hs.status = "Healthy"
hs.message = condition.message
return hs
end
end
end
end
hs.status = "Progressing"
hs.message = "Waiting for Reconcile"
return hs