Dabz / ccloudexporter

Prometheus exporter for Confluent Cloud API metric
https://docs.confluent.io/current/cloud/metrics-api.html
87 stars 53 forks source link

Add schema registry metrics #77

Closed sebco59 closed 3 years ago

sebco59 commented 3 years ago

Add schema registry metrics in order to expose schema count (based on the connector_ksql.go)

A new resource type is available schema_registry (https://api.telemetry.confluent.cloud/docs)

curl https://api.telemetry.confluent.cloud/v2/metrics/cloud/descriptors/metrics?resource_type=schema_registry

and is in GA !

{
    "data": [
        {
            "name": "io.confluent.kafka.schema_registry/schema_count",
            "description": "The number of registered schemas.",
            "type": "GAUGE_INT64",
            "unit": "1",
            "lifecycle_stage": "GENERAL_AVAILABILITY",
            "labels": []
        }
    ],
    "meta": {
        "pagination": {
            "page_size": 100,
            "total_size": 1
        }
    },
    "links": {}
}

Metrics can be get by this call

curl --request POST 'https://api.telemetry.confluent.cloud/v2/metrics/cloud/query' \
    --data-raw '{
        "aggregations": [
            {
                "agg": "SUM",
                "metric": "io.confluent.kafka.schema_registry/schema_count"
            }
        ],
        "filter": {
            "filters": [
                {
                    "field": "resource.schema_registry.id",
                    "op": "EQ",
                    "value": "lsrc-abcde"
                }
            ],
            "op": "AND"
        },
        "granularity": "PT1M",
        "group_by": [
        ],
        "intervals": [
            "2021-06-03T10:00:00+01:00/2021-06-03T11:00:00+01:00"
        ],
        "limit": 500
    }'
sebco59 commented 3 years ago

Fix #64

Dabz commented 3 years ago

Thanks @sebco59 for the PR. It looks good to me. Let me merge it, a new docker image should be available a few minutes after the merge.