> For the complete documentation index, see [llms.txt](https://rc.sunbird.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rc.sunbird.org/use/developer-guide/metrics.md).

# Metrics

Sunbird RC can emit `ADD`/`UPDATE`/`DELETE`/`READ` events from the registry, in the Sunbird telemetry event format. Enable with `event_enabled=true`, set `event_topic`, and set `event_providerName` to one of the providers below.

Sample event:

```json
{
  "eid": "ADD", "ets": 1678958110872, "ver": "3.1", "mid": "abc-123",
  "actor": { "id": "123", "type": "User" },
  "context": { "channel": "sunbird-rc-core", "env": "dev" },
  "object": { "id": "xyz-123", "type": "Student" },
  "edata": { "...": "entity fields, masked per the schema's privateFields/internalFields config" }
}
```

{% tabs %}
{% tab title="Kafka-based" %}
`event_providerName=dev.sunbirdrc.registry.service.impl.KafkaEventService`

The registry publishes to the configured topic (default `events`); a consumer stores it in Clickhouse. Entity data is masked per the schema's `privateFields`/`internalFields` config.
{% endtab %}

{% tab title="File-based" %}
`event_providerName=dev.sunbirdrc.registry.service.impl.FileEventService.java`

Events are appended to `metrics_log/metrics.log`, with a 30 MB rolling policy.
{% endtab %}
{% endtabs %}

## Metrics Service

The Kafka consumer, using Clickhouse by default:

```sql
create table <table_name> (
  operationType String,
  createdAt Date,
  entityId String,
  entity JSON
)
```

One table per distinct schema type. Exposes two APIs: an event-count API (across all tables) and an aggregates API — a cron job computes aggregates and caches them in Redis, served from there. Configure the cron with `CRON_ENABLE`, `SCHEDULE_INTERVAL` (days), `SCHEDULE_TIME` (GMT).

{% hint style="info" %}
See the [full discussion](https://github.com/orgs/Sunbird-RC/discussions/) for the end-to-end interaction diagram.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://rc.sunbird.org/use/developer-guide/metrics.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
