diff --git a/crowdsec-docs/unversioned/service_api/quickstart/metrics.mdx b/crowdsec-docs/unversioned/service_api/quickstart/metrics.mdx index b56a6ed82..7bbba34ff 100644 --- a/crowdsec-docs/unversioned/service_api/quickstart/metrics.mdx +++ b/crowdsec-docs/unversioned/service_api/quickstart/metrics.mdx @@ -85,6 +85,83 @@ print(response.model_dump_json()) +### Get Remediation Metrics by Engine IDs or Tags + +:::info + - You can filter the metrics by specifying security engine IDs or tags. +::: + + + + + +```bash +curl -i -H "x-api-key: ${KEY}" -X GET -H "Content-Type: application/json" \ +https://admin.api.crowdsec.net/v1/metrics/remediation?start_date=2025-03-19T00:00:00Z&end_date=2025-03-27T00:00:00Z&engine_ids=a1b2c3d4e5f6g7h8i9j0&engine_ids=0j9i8h7g6f5e4d3c2b1a +``` + + + + +```python +import os + +KEY = os.getenv('KEY') + +from crowdsec_service_api import ( + Metrics, + Server, + ApiKeyAuth, +) + +auth = ApiKeyAuth(api_key=KEY) + +client = Metrics(base_url=Server.production_server.value, auth=auth) +# Get remediation metrics +response = metrics_client.get_metrics_remediation( + start_date=datetime.datetime.now() - datetime.timedelta(days=1), + end_date=datetime.datetime.now(), + engine_ids=["a1b2c3d4e5f6g7h8i9j0", "0j9i8h7g6f5e4d3c2b1a"], + tags=["tag1", "tag2"], +) +print(response.model_dump_json()) +``` + + + + + - [Swagger method link](https://admin.api.crowdsec.net/v1/docs#/Metrics/getMetricsRemediation) + +
+ answer on success + +```json +{ + "raw": { + "dropped": [], + "processed": [] + }, + "computed": { + "saved": { + "log_lines": [], + "storage": [], + "egress_traffic": [] + }, + "dropped": [], + "prevented": [] + } +} +``` + +
+ ### Metrics definitions - `raw`: Raw metrics are the metrics that are directly collected from the crowdsec engine.