Skip to content

Event to metric#879

Open
DmitryRomanov wants to merge 3 commits intomasterfrom
event_to_metric
Open

Event to metric#879
DmitryRomanov wants to merge 3 commits intomasterfrom
event_to_metric

Conversation

@DmitryRomanov
Copy link
Copy Markdown
Collaborator

@DmitryRomanov DmitryRomanov commented Jul 3, 2025

Description

Calculate metrics from event and send them to the Prometheus

Config:

pipelines:
	metrics:
	    actions:
	    - type: event_to_metrics
	        config:
	        time_field: timestamp
	        time_field_format: rfc3339
	        metrics:
	            # Counter for total requests
	            - name: http_requests_total
	            type: counter
	            value: []
	            ttl: 60s
	            labels:
	                service: api
	                method: request.method
	                path: request.path
	                status: response.status_code

	            # Gauge for response time
	            - name: http_response_time_ms
	            type: gauge
	            value:
	                - response.duration_ms
	            ttl: 5m
	            labels:
	                service: api
	                method: request.method
	                path: request.path

	    output:
		    plugin: prometheus
		    config:
		        # Prometheus remote write endpoint
		        endpoint: http://localhost:9090/api/v1/write

Input event:

{
    "timestamp": "2024-01-15T10:30:00Z",
    "request": {
        "method": "GET",
        "path": "/api/users/123"
    },
    "response": {
        "status_code": "200",
        "duration_ms": 45.3
    }
}

The plugin will generate the following metrics that get sent to Prometheus:

http_requests_total{service="api", method="GET", path="/api/users/123", `status="200"}=1
http_response_time_ms{service="api"`, method="GET"`, path="/api/users/123"} = 45.3

@DmitryRomanov DmitryRomanov marked this pull request as ready for review April 15, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant