Skip to content

Database Metrics Doesn't Exist

Errors

Key errors
bash
{
  "kind": "exporter",
  "data_type": "logs",
  "name": "clickhouse",
  "error": "PrepareContext:code: 81, message: Database metrics doesn't exist",
  "interval": "14.932404217s"
}
Source
bash
2025-01-08T03:43:01.128Z        info    internal/retry_sender.go:126    Exporting failed. Will retry the request after interval.        {"kind": "exporter", "data_type": "logs", "name": "clickhouse", "error": "PrepareContext:code: 81, message: Database metrics doesn't exist", "interval": "14.932404217s"}
ClickHouse Exporter
yaml
exporters:
  clickhouse:
    database: journal
    endpoint: tcp://clickhouse.monitor.svc.cluster.local:9000
    logs_table_name: otel_logs

What the Fuck? ClickHouse Exporter has no metrics database.

Explaination

Because of ClickVisual Metrics MATERIALIZED VIEW. It will listen journal.otel_logs table and write to metrics.samples.

sql
CREATE MATERIALIZED VIEW xx.xx
TO metrics.samples AS
SELECT
    toDate(_time_second_) AS date,
    'clickvisual_alert_metrics' AS name,
    array('uuid=6ec0fd1c-0103-4d28-abb5-b317e5977c0c') AS tags,
    toFloat64(count(*)) AS val,
    _time_second_ AS ts,
    toDateTime(_time_second_) AS updated
FROM journal.otel_logs
WHERE
    (
        _container_name_ = 'app'
        OR _container_name_ = 'app'
    )
    AND _namespace_ = 'default'
    AND code > '499'
GROUP BY
    _time_second_;