I. Overview
The Label Mapping API allows you to build custom external services to enrich alert labels. The workflow is as follows:- Flashduty receives an alert event
- The system sends event information and the list of expected labels to your API based on configuration
- Your API queries external data sources (such as CMDB, databases, etc.)
- The API returns the computed enrichment labels
- Flashduty attaches the returned labels to the alert
II. API Specification
Request Method
POST, Content-Type:“application/json”
Request Payload:
Event:
Request Example
Response Specification
Successful Response:Failure Response:
- HTTP Status Code:
200 OK - Response body must be a JSON object containing the
result_labelsfield - Keys in
result_labelsmust be label names specified in the request’sresult_label_keys - If a label cannot be retrieved, it should not be included in the response
Note: Returning200 OKstatus code with an emptyresult_labels: {}object will also be treated as “no results”, but using the404status code is the more standard approach.
III. Configure Mapping Service
When configuring label mapping in Flashduty, you need to first create a mapping service, then reference that service in your label enrichment rules.Mapping Service Field Description
Label Enrichment Rule Configuration
When configuring label enrichment rules, you only need to focus on the following settings:- result_label_keys: Specify the list of labels you expect to retrieve from the API. Flashduty will automatically combine this list with the current
eventobject into a request body and send it to your API - Mapping Service: Select or configure the API service URL, Headers, and other information
IV. Header Security Constraints
To prevent security bypasses, request smuggling, IP spoofing, and cache poisoning, the following Headers are prohibited when customizing API request headers. The system gateway will automatically filter or reject requests containing these Headers.Header Best Practices
- Allowlist Mode: It is recommended to only allow custom Headers prefixed with
X-Custom-orX-Enrich- - Length Limits: The Key or Value length of a single Header should not exceed 1024 bytes
- Format Validation: Header Values must not contain line breaks (
\r,\n) to prevent Header injection attacks
V. Best Practices
- Performance First: This API is on the critical path of alert processing and must ensure low latency. Queries to external data sources should be as fast as possible, and implementing caching is recommended.
-
Clear Error Handling: Make good use of HTTP status codes (especially
404) to convey clear execution results. -
Idempotency: The API design should be as idempotent as possible. Multiple calls for the same
eventshould return the same result. -
Security: The API must be protected through authentication and authorization mechanisms. Using custom Headers (e.g.,
X-Custom-Auth) for passing authentication information is recommended.
VI. FAQ
-
Is there a response timeout for the service?
- The service must respond within the configured timeout period; exceeding this is considered a failure
-
What happens if the API returns a failure?
- The alert will be processed normally, but no enrichment labels will be attached
- Based on the configured retry count, the system may retry the request
-
Can result_label_keys be changed dynamically?
- Yes, you can modify the list of expected labels in Flashduty at any time without modifying the API code