@grantex/destinations package includes a DatadogDestination that sends Grantex events to the Datadog Logs API. This guide covers setup, configuration, and example monitors for production alerting.
Prerequisites
- A Datadog account with a Logs API key (not an application key)
- The
@grantex/destinationspackage installed:
Setup
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | required | Datadog API key for the Logs API |
site | string | datadoghq.com | Datadog site (e.g., datadoghq.eu, us5.datadoghq.com) |
service | string | grantex | Service name tag applied to all logs |
source | string | grantex | Source tag (ddsource) applied to all logs |
batchSize | number | 100 | Number of events to buffer before flushing to Datadog |
flushIntervalMs | number | — | Flush buffered events on a timer (milliseconds) |
How It Works
TheDatadogDestination buffers incoming events and flushes them in batches to the Datadog Logs HTTP API (POST https://http-intake.logs.<site>/api/v2/logs).
Each Grantex event becomes a Datadog log entry with:
| Field | Value |
|---|---|
ddsource | Value of source config (default: grantex) |
ddtags | type:<event-type> (e.g., type:grant.created) |
hostname | grantex-auth-service |
service | Value of service config (default: grantex) |
message | Full JSON-serialized Grantex event |
Filtering Event Types
To send only specific events to Datadog, filter at theEventSource level:
Datadog Log Pipeline
Create a Datadog log pipeline to parse Grantex events:- Go to Logs > Configuration > Pipelines
- Create a new pipeline with filter
source:grantex - Add a JSON Mapper processor to extract fields from
message:event.type->grantex.event_typeevent.data.grantId->grantex.grant_idevent.data.agentId->grantex.agent_idevent.data.principalId->grantex.principal_idevent.data.scopes->grantex.scopes
- Add a Category Processor on
grantex.event_typeto set severity:grant.revoked->warnbudget.exhausted->error- Everything else ->
info
Example Monitors
High Grant Revocation Rate
Alert when grant revocations exceed a threshold, which may indicate a security incident or misconfigured agent.Budget Exhaustion
Alert immediately when any budget is fully consumed.No Events Received (Heartbeat)
Detect if the event stream connection drops.Anomalous Token Issuance
Detect spikes in token issuance that deviate from the baseline.Datadog Dashboard
Create a dashboard with these widgets for a Grantex overview:| Widget | Query | Visualization |
|---|---|---|
| Events by type | source:grantex group by @grantex.event_type | Timeseries (stacked bars) |
| Grants created | source:grantex type:grant.created | Query Value |
| Grants revoked | source:grantex type:grant.revoked | Query Value |
| Budget alerts | source:grantex type:budget.* | Event Stream |
| Top agents | source:grantex group by @grantex.agent_id | Top List |
Graceful Shutdown
Ensure buffered events are flushed before your process exits:Next Steps
- Event Streaming — SSE/WebSocket architecture overview
- Splunk Integration — forward events to Splunk HEC
- S3 & BigQuery Archival — long-term compliance storage
- Metrics & Observability — Prometheus metrics and Grafana dashboards