curl --request POST \
--url https://api.coralogix.com/mgmt/openapi/5/alerts/alerts/v3/all/create \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"alertDefsToCreate": [
{
"alertDefProperties": {
"logsImmediate": {
"logsFilter": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"notificationPayloadFilter": [
"obj.field"
]
},
"activeOn": {
"dayOfWeek": [
"DAY_OF_WEEK_MONDAY_OR_UNSPECIFIED",
"DAY_OF_WEEK_TUESDAY"
],
"endTime": {
"hours": 14,
"minutes": 30
},
"startTime": {
"hours": 14,
"minutes": 30
}
},
"analyticsImmediate": {
"dataprimeQuery": {
"query": "source logs | filter severity == 'error' | count_agg_key by applicationName"
},
"evaluationDelayMs": 300000,
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"timeframeMinutes": 60,
"useRowsAsPermutations": false
},
"analyticsThreshold": {
"dataprimeQuery": {
"query": "source logs | filter severity == 'error' | count_agg_key by applicationName"
},
"evaluationDelayMs": 300000,
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"operator": "ANALYTICS_THRESHOLD_OPERATOR_MORE_THAN_OR_UNSPECIFIED",
"rules": [
{
"condition": {
"threshold": 100
},
"override": {
"priority": "ALERT_DEF_PRIORITY_P3"
}
}
],
"targetColumn": "error_count",
"timeframeMinutes": 60,
"useRowsAsPermutations": true
},
"dataSources": [
{
"dataSet": "<string>",
"dataSpace": "<string>"
}
],
"deleted": false,
"description": "Alert description",
"enabled": true,
"entityLabels": {},
"flow": {
"enforceSuppression": true,
"stages": [
{
"flowStagesGroups": {
"groups": [
{
"alertDefs": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"not": true
}
],
"alertsOp": "ALERTS_OP_OR",
"nextOp": "NEXT_OP_OR"
}
]
},
"timeframeMs": "<string>",
"timeframeType": "TIMEFRAME_TYPE_UP_TO"
}
]
},
"groupByKeys": [
"key1",
"key2"
],
"incidentsSettings": {
"minutes": 30,
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED"
},
"logsAnomaly": {
"anomalyAlertSettings": {
"percentageOfDeviation": 1
},
"evaluationDelayMs": 60000,
"logsFilter": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"notificationPayloadFilter": [
"obj.field"
],
"rules": [
{
"condition": {
"conditionType": "LOGS_ANOMALY_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"minimumThreshold": 10,
"timeWindow": {
"logsTimeWindowSpecificValue": "LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED"
}
}
}
]
},
"logsNewValue": {
"logsFilter": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"notificationPayloadFilter": [
"obj.field"
],
"rules": [
{
"condition": {
"keypathToTrack": "metadata.field",
"timeWindow": {
"logsNewValueTimeWindowSpecificValue": "LOGS_NEW_VALUE_TIME_WINDOW_VALUE_HOURS_12_OR_UNSPECIFIED"
}
}
}
]
},
"logsRatioThreshold": {
"denominator": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"denominatorAlias": "denominator_alias",
"evaluationDelayMs": 60000,
"groupByFor": "LOGS_RATIO_GROUP_BY_FOR_NUMERATOR_ONLY",
"ignoreInfinity": true,
"notificationPayloadFilter": [
"obj.field"
],
"numerator": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"numeratorAlias": "numerator_alias",
"rules": [
{
"condition": {
"conditionType": "LOGS_RATIO_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"threshold": 10,
"timeWindow": 10
},
"override": {
"priority": "ALERT_DEF_PRIORITY_P3"
}
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": true
}
},
"logsThreshold": {
"evaluationDelayMs": 60000,
"logsFilter": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"notificationPayloadFilter": [
"obj.field"
],
"rules": [
{
"condition": {
"conditionType": "LOGS_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"threshold": 100,
"timeWindow": {
"logsTimeWindowSpecificValue": "LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED"
}
},
"override": {
"priority": "ALERT_DEF_PRIORITY_P3"
}
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": true
}
},
"logsTimeRelativeThreshold": {
"evaluationDelayMs": 60000,
"ignoreInfinity": true,
"logsFilter": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"notificationPayloadFilter": [
"obj.field"
],
"rules": [
{
"condition": {
"comparedTo": "LOGS_TIME_RELATIVE_COMPARED_TO_YESTERDAY",
"conditionType": "LOGS_TIME_RELATIVE_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"threshold": 1
},
"override": {
"priority": "ALERT_DEF_PRIORITY_P3"
}
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": true
}
},
"logsUniqueCount": {
"logsFilter": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"maxUniqueCountPerGroupByKey": "100",
"notificationPayloadFilter": [
"obj.field"
],
"rules": [
{
"condition": {
"maxUniqueCount": "100",
"timeWindow": {
"logsUniqueValueTimeWindowSpecificValue": "LOGS_UNIQUE_VALUE_TIME_WINDOW_VALUE_HOURS_12"
}
}
}
],
"uniqueCountKeypath": "obj.field"
},
"metricAnomaly": {
"anomalyAlertSettings": {
"percentageOfDeviation": 1
},
"evaluationDelayMs": 60000,
"metricFilter": {
"promql": "avg_over_time(metric_name[5m]) > 10"
},
"rules": [
{
"condition": {
"conditionType": "METRIC_ANOMALY_CONDITION_TYPE_LESS_THAN_USUAL",
"forOverPct": 20,
"minNonNullValuesPct": 10,
"ofTheLast": {
"metricTimeWindowSpecificValue": "METRIC_TIME_WINDOW_VALUE_MINUTES_5",
"metricTimeWindowDynamicDuration": "1h30m"
},
"threshold": 10
}
}
]
},
"metricThreshold": {
"evaluationDelayMs": 60000,
"metricFilter": {
"promql": "avg_over_time(metric_name[5m]) > 10"
},
"missingValues": {
"replaceWithZero": true,
"minNonNullValuesPct": 80
},
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"rules": [
{
"condition": {
"conditionType": "METRIC_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_EQUALS",
"forOverPct": 80,
"ofTheLast": {
"metricTimeWindowSpecificValue": "METRIC_TIME_WINDOW_VALUE_MINUTES_5",
"metricTimeWindowDynamicDuration": "1h30m"
},
"threshold": 100
},
"override": {
"priority": "ALERT_DEF_PRIORITY_P3"
}
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": true
}
},
"name": "My Alert",
"notificationGroup": {
"destinations": [
{
"connectorId": "connector_id_example",
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED",
"presetId": "preset_id_example",
"resolvedRouteOverrides": {
"configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
}
},
"retriggeringPeriodMinutes": 600,
"triggeredRoutingOverrides": {
"configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
}
}
}
],
"groupByKeys": [
"key1",
"key2"
],
"router": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"notifyOn": "NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED"
},
"webhooks": [
{
"integration": {
"integrationId": 123,
"recipients": {
"emails": [
"mail@gmail.com"
]
}
},
"minutes": 15,
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED"
}
]
},
"notificationGroupExcess": [
{
"destinations": [
{
"connectorId": "connector_id_example",
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED",
"presetId": "preset_id_example",
"resolvedRouteOverrides": {
"configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
}
},
"retriggeringPeriodMinutes": 600,
"triggeredRoutingOverrides": {
"configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
}
}
}
],
"groupByKeys": [
"key1",
"key2"
],
"router": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"notifyOn": "NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED"
},
"webhooks": [
{
"integration": {
"integrationId": 123,
"recipients": {
"emails": [
"mail@gmail.com"
]
}
},
"minutes": 15,
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED"
}
]
}
],
"phantomMode": false,
"priority": "ALERT_DEF_PRIORITY_P4",
"sloThreshold": {
"errorBudget": {
"rules": [
{
"condition": {
"threshold": 1
},
"override": {
"priority": "ALERT_DEF_PRIORITY_P3"
}
}
]
},
"burnRate": {
"dual": {
"timeDuration": {
"duration": "24",
"unit": "DURATION_UNIT_HOURS"
}
},
"rules": [
{
"condition": {
"threshold": 1
},
"override": {
"priority": "ALERT_DEF_PRIORITY_P3"
}
}
],
"single": {
"timeDuration": {
"duration": "24",
"unit": "DURATION_UNIT_HOURS"
}
}
},
"sloDefinition": {
"sloId": "123e4567-e89b-12d3-a456-426614174000"
}
},
"tracingImmediate": {
"notificationPayloadFilter": [
"obj.field"
],
"tracingFilter": {
"simpleFilter": {
"latencyThresholdMs": "1000",
"tracingLabelFilters": {
"applicationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
],
"operationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
],
"serviceName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
],
"spanFields": [
{
"filterType": {
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
},
"key": "span.field.key"
}
],
"subsystemName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
]
}
}
}
},
"tracingThreshold": {
"notificationPayloadFilter": [
"obj.field"
],
"rules": [
{
"condition": {
"conditionType": "TRACING_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"spanAmount": 100,
"timeWindow": {
"tracingTimeWindowValue": "TRACING_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED"
}
}
}
],
"tracingFilter": {
"simpleFilter": {
"latencyThresholdMs": "1000",
"tracingLabelFilters": {
"applicationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
],
"operationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
],
"serviceName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
],
"spanFields": [
{
"filterType": {
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
},
"key": "span.field.key"
}
],
"subsystemName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
]
}
}
}
},
"type": "ALERT_DEF_TYPE_METRIC_THRESHOLD"
},
"accessPolicy": "<string>"
}
]
}
EOFimport requests
url = "https://api.coralogix.com/mgmt/openapi/5/alerts/alerts/v3/all/create"
payload = { "alertDefsToCreate": [
{
"alertDefProperties": {
"logsImmediate": {
"logsFilter": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"notificationPayloadFilter": ["obj.field"]
},
"activeOn": {
"dayOfWeek": ["DAY_OF_WEEK_MONDAY_OR_UNSPECIFIED", "DAY_OF_WEEK_TUESDAY"],
"endTime": {
"hours": 14,
"minutes": 30
},
"startTime": {
"hours": 14,
"minutes": 30
}
},
"analyticsImmediate": {
"dataprimeQuery": { "query": "source logs | filter severity == 'error' | count_agg_key by applicationName" },
"evaluationDelayMs": 300000,
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"timeframeMinutes": 60,
"useRowsAsPermutations": False
},
"analyticsThreshold": {
"dataprimeQuery": { "query": "source logs | filter severity == 'error' | count_agg_key by applicationName" },
"evaluationDelayMs": 300000,
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"operator": "ANALYTICS_THRESHOLD_OPERATOR_MORE_THAN_OR_UNSPECIFIED",
"rules": [
{
"condition": { "threshold": 100 },
"override": { "priority": "ALERT_DEF_PRIORITY_P3" }
}
],
"targetColumn": "error_count",
"timeframeMinutes": 60,
"useRowsAsPermutations": True
},
"dataSources": [
{
"dataSet": "<string>",
"dataSpace": "<string>"
}
],
"deleted": False,
"description": "Alert description",
"enabled": True,
"entityLabels": {},
"flow": {
"enforceSuppression": True,
"stages": [
{
"flowStagesGroups": { "groups": [
{
"alertDefs": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"not": True
}
],
"alertsOp": "ALERTS_OP_OR",
"nextOp": "NEXT_OP_OR"
}
] },
"timeframeMs": "<string>",
"timeframeType": "TIMEFRAME_TYPE_UP_TO"
}
]
},
"groupByKeys": ["key1", "key2"],
"incidentsSettings": {
"minutes": 30,
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED"
},
"logsAnomaly": {
"anomalyAlertSettings": { "percentageOfDeviation": 1 },
"evaluationDelayMs": 60000,
"logsFilter": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"notificationPayloadFilter": ["obj.field"],
"rules": [{ "condition": {
"conditionType": "LOGS_ANOMALY_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"minimumThreshold": 10,
"timeWindow": { "logsTimeWindowSpecificValue": "LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED" }
} }]
},
"logsNewValue": {
"logsFilter": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"notificationPayloadFilter": ["obj.field"],
"rules": [{ "condition": {
"keypathToTrack": "metadata.field",
"timeWindow": { "logsNewValueTimeWindowSpecificValue": "LOGS_NEW_VALUE_TIME_WINDOW_VALUE_HOURS_12_OR_UNSPECIFIED" }
} }]
},
"logsRatioThreshold": {
"denominator": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"denominatorAlias": "denominator_alias",
"evaluationDelayMs": 60000,
"groupByFor": "LOGS_RATIO_GROUP_BY_FOR_NUMERATOR_ONLY",
"ignoreInfinity": True,
"notificationPayloadFilter": ["obj.field"],
"numerator": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"numeratorAlias": "numerator_alias",
"rules": [
{
"condition": {
"conditionType": "LOGS_RATIO_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"threshold": 10,
"timeWindow": 10
},
"override": { "priority": "ALERT_DEF_PRIORITY_P3" }
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": True
}
},
"logsThreshold": {
"evaluationDelayMs": 60000,
"logsFilter": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"notificationPayloadFilter": ["obj.field"],
"rules": [
{
"condition": {
"conditionType": "LOGS_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"threshold": 100,
"timeWindow": { "logsTimeWindowSpecificValue": "LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED" }
},
"override": { "priority": "ALERT_DEF_PRIORITY_P3" }
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": True
}
},
"logsTimeRelativeThreshold": {
"evaluationDelayMs": 60000,
"ignoreInfinity": True,
"logsFilter": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"notificationPayloadFilter": ["obj.field"],
"rules": [
{
"condition": {
"comparedTo": "LOGS_TIME_RELATIVE_COMPARED_TO_YESTERDAY",
"conditionType": "LOGS_TIME_RELATIVE_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"threshold": 1
},
"override": { "priority": "ALERT_DEF_PRIORITY_P3" }
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": True
}
},
"logsUniqueCount": {
"logsFilter": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"maxUniqueCountPerGroupByKey": "100",
"notificationPayloadFilter": ["obj.field"],
"rules": [{ "condition": {
"maxUniqueCount": "100",
"timeWindow": { "logsUniqueValueTimeWindowSpecificValue": "LOGS_UNIQUE_VALUE_TIME_WINDOW_VALUE_HOURS_12" }
} }],
"uniqueCountKeypath": "obj.field"
},
"metricAnomaly": {
"anomalyAlertSettings": { "percentageOfDeviation": 1 },
"evaluationDelayMs": 60000,
"metricFilter": { "promql": "avg_over_time(metric_name[5m]) > 10" },
"rules": [{ "condition": {
"conditionType": "METRIC_ANOMALY_CONDITION_TYPE_LESS_THAN_USUAL",
"forOverPct": 20,
"minNonNullValuesPct": 10,
"ofTheLast": {
"metricTimeWindowSpecificValue": "METRIC_TIME_WINDOW_VALUE_MINUTES_5",
"metricTimeWindowDynamicDuration": "1h30m"
},
"threshold": 10
} }]
},
"metricThreshold": {
"evaluationDelayMs": 60000,
"metricFilter": { "promql": "avg_over_time(metric_name[5m]) > 10" },
"missingValues": {
"replaceWithZero": True,
"minNonNullValuesPct": 80
},
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"rules": [
{
"condition": {
"conditionType": "METRIC_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_EQUALS",
"forOverPct": 80,
"ofTheLast": {
"metricTimeWindowSpecificValue": "METRIC_TIME_WINDOW_VALUE_MINUTES_5",
"metricTimeWindowDynamicDuration": "1h30m"
},
"threshold": 100
},
"override": { "priority": "ALERT_DEF_PRIORITY_P3" }
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": True
}
},
"name": "My Alert",
"notificationGroup": {
"destinations": [
{
"connectorId": "connector_id_example",
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED",
"presetId": "preset_id_example",
"resolvedRouteOverrides": { "configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
} },
"retriggeringPeriodMinutes": 600,
"triggeredRoutingOverrides": { "configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
} }
}
],
"groupByKeys": ["key1", "key2"],
"router": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"notifyOn": "NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED"
},
"webhooks": [
{
"integration": {
"integrationId": 123,
"recipients": { "emails": ["mail@gmail.com"] }
},
"minutes": 15,
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED"
}
]
},
"notificationGroupExcess": [
{
"destinations": [
{
"connectorId": "connector_id_example",
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED",
"presetId": "preset_id_example",
"resolvedRouteOverrides": { "configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
} },
"retriggeringPeriodMinutes": 600,
"triggeredRoutingOverrides": { "configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
} }
}
],
"groupByKeys": ["key1", "key2"],
"router": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"notifyOn": "NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED"
},
"webhooks": [
{
"integration": {
"integrationId": 123,
"recipients": { "emails": ["mail@gmail.com"] }
},
"minutes": 15,
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED"
}
]
}
],
"phantomMode": False,
"priority": "ALERT_DEF_PRIORITY_P4",
"sloThreshold": {
"errorBudget": { "rules": [
{
"condition": { "threshold": 1 },
"override": { "priority": "ALERT_DEF_PRIORITY_P3" }
}
] },
"burnRate": {
"dual": { "timeDuration": {
"duration": "24",
"unit": "DURATION_UNIT_HOURS"
} },
"rules": [
{
"condition": { "threshold": 1 },
"override": { "priority": "ALERT_DEF_PRIORITY_P3" }
}
],
"single": { "timeDuration": {
"duration": "24",
"unit": "DURATION_UNIT_HOURS"
} }
},
"sloDefinition": { "sloId": "123e4567-e89b-12d3-a456-426614174000" }
},
"tracingImmediate": {
"notificationPayloadFilter": ["obj.field"],
"tracingFilter": { "simpleFilter": {
"latencyThresholdMs": "1000",
"tracingLabelFilters": {
"applicationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
],
"operationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
],
"serviceName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
],
"spanFields": [
{
"filterType": {
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
},
"key": "span.field.key"
}
],
"subsystemName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
]
}
} }
},
"tracingThreshold": {
"notificationPayloadFilter": ["obj.field"],
"rules": [{ "condition": {
"conditionType": "TRACING_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"spanAmount": 100,
"timeWindow": { "tracingTimeWindowValue": "TRACING_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED" }
} }],
"tracingFilter": { "simpleFilter": {
"latencyThresholdMs": "1000",
"tracingLabelFilters": {
"applicationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
],
"operationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
],
"serviceName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
],
"spanFields": [
{
"filterType": {
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
},
"key": "span.field.key"
}
],
"subsystemName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
]
}
} }
},
"type": "ALERT_DEF_TYPE_METRIC_THRESHOLD"
},
"accessPolicy": "<string>"
}
] }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
alertDefsToCreate: [
{
alertDefProperties: {
logsImmediate: {
logsFilter: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
notificationPayloadFilter: ['obj.field']
},
activeOn: {
dayOfWeek: ['DAY_OF_WEEK_MONDAY_OR_UNSPECIFIED', 'DAY_OF_WEEK_TUESDAY'],
endTime: {hours: 14, minutes: 30},
startTime: {hours: 14, minutes: 30}
},
analyticsImmediate: {
dataprimeQuery: {
query: 'source logs | filter severity == \'error\' | count_agg_key by applicationName'
},
evaluationDelayMs: 300000,
noDataPolicy: {autoRetireSeconds: 3600, state: 'NO_DATA_POLICY_STATE_ALERTING'},
timeframeMinutes: 60,
useRowsAsPermutations: false
},
analyticsThreshold: {
dataprimeQuery: {
query: 'source logs | filter severity == \'error\' | count_agg_key by applicationName'
},
evaluationDelayMs: 300000,
noDataPolicy: {autoRetireSeconds: 3600, state: 'NO_DATA_POLICY_STATE_ALERTING'},
operator: 'ANALYTICS_THRESHOLD_OPERATOR_MORE_THAN_OR_UNSPECIFIED',
rules: [{condition: {threshold: 100}, override: {priority: 'ALERT_DEF_PRIORITY_P3'}}],
targetColumn: 'error_count',
timeframeMinutes: 60,
useRowsAsPermutations: true
},
dataSources: [{dataSet: '<string>', dataSpace: '<string>'}],
deleted: false,
description: 'Alert description',
enabled: true,
entityLabels: {},
flow: {
enforceSuppression: true,
stages: [
{
flowStagesGroups: {
groups: [
{
alertDefs: [{id: '123e4567-e89b-12d3-a456-426614174000', not: true}],
alertsOp: 'ALERTS_OP_OR',
nextOp: 'NEXT_OP_OR'
}
]
},
timeframeMs: '<string>',
timeframeType: 'TIMEFRAME_TYPE_UP_TO'
}
]
},
groupByKeys: ['key1', 'key2'],
incidentsSettings: {minutes: 30, notifyOn: 'NOTIFY_ON_TRIGGERED_AND_RESOLVED'},
logsAnomaly: {
anomalyAlertSettings: {percentageOfDeviation: 1},
evaluationDelayMs: 60000,
logsFilter: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
notificationPayloadFilter: ['obj.field'],
rules: [
{
condition: {
conditionType: 'LOGS_ANOMALY_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
minimumThreshold: 10,
timeWindow: {logsTimeWindowSpecificValue: 'LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED'}
}
}
]
},
logsNewValue: {
logsFilter: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
notificationPayloadFilter: ['obj.field'],
rules: [
{
condition: {
keypathToTrack: 'metadata.field',
timeWindow: {
logsNewValueTimeWindowSpecificValue: 'LOGS_NEW_VALUE_TIME_WINDOW_VALUE_HOURS_12_OR_UNSPECIFIED'
}
}
}
]
},
logsRatioThreshold: {
denominator: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
denominatorAlias: 'denominator_alias',
evaluationDelayMs: 60000,
groupByFor: 'LOGS_RATIO_GROUP_BY_FOR_NUMERATOR_ONLY',
ignoreInfinity: true,
notificationPayloadFilter: ['obj.field'],
numerator: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
numeratorAlias: 'numerator_alias',
rules: [
{
condition: {
conditionType: 'LOGS_RATIO_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
threshold: 10,
timeWindow: 10
},
override: {priority: 'ALERT_DEF_PRIORITY_P3'}
}
],
undetectedValuesManagement: {
autoRetireTimeframe: 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
triggerUndetectedValues: true
}
},
logsThreshold: {
evaluationDelayMs: 60000,
logsFilter: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
noDataPolicy: {autoRetireSeconds: 3600, state: 'NO_DATA_POLICY_STATE_ALERTING'},
notificationPayloadFilter: ['obj.field'],
rules: [
{
condition: {
conditionType: 'LOGS_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
threshold: 100,
timeWindow: {logsTimeWindowSpecificValue: 'LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED'}
},
override: {priority: 'ALERT_DEF_PRIORITY_P3'}
}
],
undetectedValuesManagement: {
autoRetireTimeframe: 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
triggerUndetectedValues: true
}
},
logsTimeRelativeThreshold: {
evaluationDelayMs: 60000,
ignoreInfinity: true,
logsFilter: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
notificationPayloadFilter: ['obj.field'],
rules: [
{
condition: {
comparedTo: 'LOGS_TIME_RELATIVE_COMPARED_TO_YESTERDAY',
conditionType: 'LOGS_TIME_RELATIVE_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
threshold: 1
},
override: {priority: 'ALERT_DEF_PRIORITY_P3'}
}
],
undetectedValuesManagement: {
autoRetireTimeframe: 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
triggerUndetectedValues: true
}
},
logsUniqueCount: {
logsFilter: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
maxUniqueCountPerGroupByKey: '100',
notificationPayloadFilter: ['obj.field'],
rules: [
{
condition: {
maxUniqueCount: '100',
timeWindow: {
logsUniqueValueTimeWindowSpecificValue: 'LOGS_UNIQUE_VALUE_TIME_WINDOW_VALUE_HOURS_12'
}
}
}
],
uniqueCountKeypath: 'obj.field'
},
metricAnomaly: {
anomalyAlertSettings: {percentageOfDeviation: 1},
evaluationDelayMs: 60000,
metricFilter: {promql: 'avg_over_time(metric_name[5m]) > 10'},
rules: [
{
condition: {
conditionType: 'METRIC_ANOMALY_CONDITION_TYPE_LESS_THAN_USUAL',
forOverPct: 20,
minNonNullValuesPct: 10,
ofTheLast: {
metricTimeWindowSpecificValue: 'METRIC_TIME_WINDOW_VALUE_MINUTES_5',
metricTimeWindowDynamicDuration: '1h30m'
},
threshold: 10
}
}
]
},
metricThreshold: {
evaluationDelayMs: 60000,
metricFilter: {promql: 'avg_over_time(metric_name[5m]) > 10'},
missingValues: {replaceWithZero: true, minNonNullValuesPct: 80},
noDataPolicy: {autoRetireSeconds: 3600, state: 'NO_DATA_POLICY_STATE_ALERTING'},
rules: [
{
condition: {
conditionType: 'METRIC_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_EQUALS',
forOverPct: 80,
ofTheLast: {
metricTimeWindowSpecificValue: 'METRIC_TIME_WINDOW_VALUE_MINUTES_5',
metricTimeWindowDynamicDuration: '1h30m'
},
threshold: 100
},
override: {priority: 'ALERT_DEF_PRIORITY_P3'}
}
],
undetectedValuesManagement: {
autoRetireTimeframe: 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
triggerUndetectedValues: true
}
},
name: 'My Alert',
notificationGroup: {
destinations: [
{
connectorId: 'connector_id_example',
notifyOn: 'NOTIFY_ON_TRIGGERED_AND_RESOLVED',
presetId: 'preset_id_example',
resolvedRouteOverrides: {
configOverrides: {
connectorConfigFields: [{fieldName: 'description', template: 'template_example'}],
messageConfigFields: [{fieldName: 'description', template: 'template_example'}],
payloadType: 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
}
},
retriggeringPeriodMinutes: 600,
triggeredRoutingOverrides: {
configOverrides: {
connectorConfigFields: [{fieldName: 'description', template: 'template_example'}],
messageConfigFields: [{fieldName: 'description', template: 'template_example'}],
payloadType: 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
}
}
}
],
groupByKeys: ['key1', 'key2'],
router: {
id: '123e4567-e89b-12d3-a456-426614174000',
notifyOn: 'NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED'
},
webhooks: [
{
integration: {integrationId: 123, recipients: {emails: ['mail@gmail.com']}},
minutes: 15,
notifyOn: 'NOTIFY_ON_TRIGGERED_AND_RESOLVED'
}
]
},
notificationGroupExcess: [
{
destinations: [
{
connectorId: 'connector_id_example',
notifyOn: 'NOTIFY_ON_TRIGGERED_AND_RESOLVED',
presetId: 'preset_id_example',
resolvedRouteOverrides: {
configOverrides: {
connectorConfigFields: [{fieldName: 'description', template: 'template_example'}],
messageConfigFields: [{fieldName: 'description', template: 'template_example'}],
payloadType: 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
}
},
retriggeringPeriodMinutes: 600,
triggeredRoutingOverrides: {
configOverrides: {
connectorConfigFields: [{fieldName: 'description', template: 'template_example'}],
messageConfigFields: [{fieldName: 'description', template: 'template_example'}],
payloadType: 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
}
}
}
],
groupByKeys: ['key1', 'key2'],
router: {
id: '123e4567-e89b-12d3-a456-426614174000',
notifyOn: 'NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED'
},
webhooks: [
{
integration: {integrationId: 123, recipients: {emails: ['mail@gmail.com']}},
minutes: 15,
notifyOn: 'NOTIFY_ON_TRIGGERED_AND_RESOLVED'
}
]
}
],
phantomMode: false,
priority: 'ALERT_DEF_PRIORITY_P4',
sloThreshold: {
errorBudget: {
rules: [{condition: {threshold: 1}, override: {priority: 'ALERT_DEF_PRIORITY_P3'}}]
},
burnRate: {
dual: {timeDuration: {duration: '24', unit: 'DURATION_UNIT_HOURS'}},
rules: [{condition: {threshold: 1}, override: {priority: 'ALERT_DEF_PRIORITY_P3'}}],
single: {timeDuration: {duration: '24', unit: 'DURATION_UNIT_HOURS'}}
},
sloDefinition: {sloId: '123e4567-e89b-12d3-a456-426614174000'}
},
tracingImmediate: {
notificationPayloadFilter: ['obj.field'],
tracingFilter: {
simpleFilter: {
latencyThresholdMs: '1000',
tracingLabelFilters: {
applicationName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
],
operationName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
],
serviceName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
],
spanFields: [
{
filterType: {
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
},
key: 'span.field.key'
}
],
subsystemName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
]
}
}
}
},
tracingThreshold: {
notificationPayloadFilter: ['obj.field'],
rules: [
{
condition: {
conditionType: 'TRACING_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
spanAmount: 100,
timeWindow: {tracingTimeWindowValue: 'TRACING_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED'}
}
}
],
tracingFilter: {
simpleFilter: {
latencyThresholdMs: '1000',
tracingLabelFilters: {
applicationName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
],
operationName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
],
serviceName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
],
spanFields: [
{
filterType: {
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
},
key: 'span.field.key'
}
],
subsystemName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
]
}
}
}
},
type: 'ALERT_DEF_TYPE_METRIC_THRESHOLD'
},
accessPolicy: '<string>'
}
]
})
};
fetch('https://api.coralogix.com/mgmt/openapi/5/alerts/alerts/v3/all/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.coralogix.com/mgmt/openapi/5/alerts/alerts/v3/all/create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'alertDefsToCreate' => [
[
'alertDefProperties' => [
'logsImmediate' => [
'logsFilter' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'notificationPayloadFilter' => [
'obj.field'
]
],
'activeOn' => [
'dayOfWeek' => [
'DAY_OF_WEEK_MONDAY_OR_UNSPECIFIED',
'DAY_OF_WEEK_TUESDAY'
],
'endTime' => [
'hours' => 14,
'minutes' => 30
],
'startTime' => [
'hours' => 14,
'minutes' => 30
]
],
'analyticsImmediate' => [
'dataprimeQuery' => [
'query' => 'source logs | filter severity == \'error\' | count_agg_key by applicationName'
],
'evaluationDelayMs' => 300000,
'noDataPolicy' => [
'autoRetireSeconds' => 3600,
'state' => 'NO_DATA_POLICY_STATE_ALERTING'
],
'timeframeMinutes' => 60,
'useRowsAsPermutations' => false
],
'analyticsThreshold' => [
'dataprimeQuery' => [
'query' => 'source logs | filter severity == \'error\' | count_agg_key by applicationName'
],
'evaluationDelayMs' => 300000,
'noDataPolicy' => [
'autoRetireSeconds' => 3600,
'state' => 'NO_DATA_POLICY_STATE_ALERTING'
],
'operator' => 'ANALYTICS_THRESHOLD_OPERATOR_MORE_THAN_OR_UNSPECIFIED',
'rules' => [
[
'condition' => [
'threshold' => 100
],
'override' => [
'priority' => 'ALERT_DEF_PRIORITY_P3'
]
]
],
'targetColumn' => 'error_count',
'timeframeMinutes' => 60,
'useRowsAsPermutations' => true
],
'dataSources' => [
[
'dataSet' => '<string>',
'dataSpace' => '<string>'
]
],
'deleted' => false,
'description' => 'Alert description',
'enabled' => true,
'entityLabels' => [
],
'flow' => [
'enforceSuppression' => true,
'stages' => [
[
'flowStagesGroups' => [
'groups' => [
[
'alertDefs' => [
[
'id' => '123e4567-e89b-12d3-a456-426614174000',
'not' => true
]
],
'alertsOp' => 'ALERTS_OP_OR',
'nextOp' => 'NEXT_OP_OR'
]
]
],
'timeframeMs' => '<string>',
'timeframeType' => 'TIMEFRAME_TYPE_UP_TO'
]
]
],
'groupByKeys' => [
'key1',
'key2'
],
'incidentsSettings' => [
'minutes' => 30,
'notifyOn' => 'NOTIFY_ON_TRIGGERED_AND_RESOLVED'
],
'logsAnomaly' => [
'anomalyAlertSettings' => [
'percentageOfDeviation' => 1
],
'evaluationDelayMs' => 60000,
'logsFilter' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'notificationPayloadFilter' => [
'obj.field'
],
'rules' => [
[
'condition' => [
'conditionType' => 'LOGS_ANOMALY_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
'minimumThreshold' => 10,
'timeWindow' => [
'logsTimeWindowSpecificValue' => 'LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED'
]
]
]
]
],
'logsNewValue' => [
'logsFilter' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'notificationPayloadFilter' => [
'obj.field'
],
'rules' => [
[
'condition' => [
'keypathToTrack' => 'metadata.field',
'timeWindow' => [
'logsNewValueTimeWindowSpecificValue' => 'LOGS_NEW_VALUE_TIME_WINDOW_VALUE_HOURS_12_OR_UNSPECIFIED'
]
]
]
]
],
'logsRatioThreshold' => [
'denominator' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'denominatorAlias' => 'denominator_alias',
'evaluationDelayMs' => 60000,
'groupByFor' => 'LOGS_RATIO_GROUP_BY_FOR_NUMERATOR_ONLY',
'ignoreInfinity' => true,
'notificationPayloadFilter' => [
'obj.field'
],
'numerator' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'numeratorAlias' => 'numerator_alias',
'rules' => [
[
'condition' => [
'conditionType' => 'LOGS_RATIO_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
'threshold' => 10,
'timeWindow' => 10
],
'override' => [
'priority' => 'ALERT_DEF_PRIORITY_P3'
]
]
],
'undetectedValuesManagement' => [
'autoRetireTimeframe' => 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
'triggerUndetectedValues' => true
]
],
'logsThreshold' => [
'evaluationDelayMs' => 60000,
'logsFilter' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'noDataPolicy' => [
'autoRetireSeconds' => 3600,
'state' => 'NO_DATA_POLICY_STATE_ALERTING'
],
'notificationPayloadFilter' => [
'obj.field'
],
'rules' => [
[
'condition' => [
'conditionType' => 'LOGS_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
'threshold' => 100,
'timeWindow' => [
'logsTimeWindowSpecificValue' => 'LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED'
]
],
'override' => [
'priority' => 'ALERT_DEF_PRIORITY_P3'
]
]
],
'undetectedValuesManagement' => [
'autoRetireTimeframe' => 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
'triggerUndetectedValues' => true
]
],
'logsTimeRelativeThreshold' => [
'evaluationDelayMs' => 60000,
'ignoreInfinity' => true,
'logsFilter' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'notificationPayloadFilter' => [
'obj.field'
],
'rules' => [
[
'condition' => [
'comparedTo' => 'LOGS_TIME_RELATIVE_COMPARED_TO_YESTERDAY',
'conditionType' => 'LOGS_TIME_RELATIVE_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
'threshold' => 1
],
'override' => [
'priority' => 'ALERT_DEF_PRIORITY_P3'
]
]
],
'undetectedValuesManagement' => [
'autoRetireTimeframe' => 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
'triggerUndetectedValues' => true
]
],
'logsUniqueCount' => [
'logsFilter' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'maxUniqueCountPerGroupByKey' => '100',
'notificationPayloadFilter' => [
'obj.field'
],
'rules' => [
[
'condition' => [
'maxUniqueCount' => '100',
'timeWindow' => [
'logsUniqueValueTimeWindowSpecificValue' => 'LOGS_UNIQUE_VALUE_TIME_WINDOW_VALUE_HOURS_12'
]
]
]
],
'uniqueCountKeypath' => 'obj.field'
],
'metricAnomaly' => [
'anomalyAlertSettings' => [
'percentageOfDeviation' => 1
],
'evaluationDelayMs' => 60000,
'metricFilter' => [
'promql' => 'avg_over_time(metric_name[5m]) > 10'
],
'rules' => [
[
'condition' => [
'conditionType' => 'METRIC_ANOMALY_CONDITION_TYPE_LESS_THAN_USUAL',
'forOverPct' => 20,
'minNonNullValuesPct' => 10,
'ofTheLast' => [
'metricTimeWindowSpecificValue' => 'METRIC_TIME_WINDOW_VALUE_MINUTES_5',
'metricTimeWindowDynamicDuration' => '1h30m'
],
'threshold' => 10
]
]
]
],
'metricThreshold' => [
'evaluationDelayMs' => 60000,
'metricFilter' => [
'promql' => 'avg_over_time(metric_name[5m]) > 10'
],
'missingValues' => [
'replaceWithZero' => true,
'minNonNullValuesPct' => 80
],
'noDataPolicy' => [
'autoRetireSeconds' => 3600,
'state' => 'NO_DATA_POLICY_STATE_ALERTING'
],
'rules' => [
[
'condition' => [
'conditionType' => 'METRIC_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_EQUALS',
'forOverPct' => 80,
'ofTheLast' => [
'metricTimeWindowSpecificValue' => 'METRIC_TIME_WINDOW_VALUE_MINUTES_5',
'metricTimeWindowDynamicDuration' => '1h30m'
],
'threshold' => 100
],
'override' => [
'priority' => 'ALERT_DEF_PRIORITY_P3'
]
]
],
'undetectedValuesManagement' => [
'autoRetireTimeframe' => 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
'triggerUndetectedValues' => true
]
],
'name' => 'My Alert',
'notificationGroup' => [
'destinations' => [
[
'connectorId' => 'connector_id_example',
'notifyOn' => 'NOTIFY_ON_TRIGGERED_AND_RESOLVED',
'presetId' => 'preset_id_example',
'resolvedRouteOverrides' => [
'configOverrides' => [
'connectorConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'messageConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'payloadType' => 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
]
],
'retriggeringPeriodMinutes' => 600,
'triggeredRoutingOverrides' => [
'configOverrides' => [
'connectorConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'messageConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'payloadType' => 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
]
]
]
],
'groupByKeys' => [
'key1',
'key2'
],
'router' => [
'id' => '123e4567-e89b-12d3-a456-426614174000',
'notifyOn' => 'NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED'
],
'webhooks' => [
[
'integration' => [
'integrationId' => 123,
'recipients' => [
'emails' => [
'mail@gmail.com'
]
]
],
'minutes' => 15,
'notifyOn' => 'NOTIFY_ON_TRIGGERED_AND_RESOLVED'
]
]
],
'notificationGroupExcess' => [
[
'destinations' => [
[
'connectorId' => 'connector_id_example',
'notifyOn' => 'NOTIFY_ON_TRIGGERED_AND_RESOLVED',
'presetId' => 'preset_id_example',
'resolvedRouteOverrides' => [
'configOverrides' => [
'connectorConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'messageConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'payloadType' => 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
]
],
'retriggeringPeriodMinutes' => 600,
'triggeredRoutingOverrides' => [
'configOverrides' => [
'connectorConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'messageConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'payloadType' => 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
]
]
]
],
'groupByKeys' => [
'key1',
'key2'
],
'router' => [
'id' => '123e4567-e89b-12d3-a456-426614174000',
'notifyOn' => 'NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED'
],
'webhooks' => [
[
'integration' => [
'integrationId' => 123,
'recipients' => [
'emails' => [
'mail@gmail.com'
]
]
],
'minutes' => 15,
'notifyOn' => 'NOTIFY_ON_TRIGGERED_AND_RESOLVED'
]
]
]
],
'phantomMode' => false,
'priority' => 'ALERT_DEF_PRIORITY_P4',
'sloThreshold' => [
'errorBudget' => [
'rules' => [
[
'condition' => [
'threshold' => 1
],
'override' => [
'priority' => 'ALERT_DEF_PRIORITY_P3'
]
]
]
],
'burnRate' => [
'dual' => [
'timeDuration' => [
'duration' => '24',
'unit' => 'DURATION_UNIT_HOURS'
]
],
'rules' => [
[
'condition' => [
'threshold' => 1
],
'override' => [
'priority' => 'ALERT_DEF_PRIORITY_P3'
]
]
],
'single' => [
'timeDuration' => [
'duration' => '24',
'unit' => 'DURATION_UNIT_HOURS'
]
]
],
'sloDefinition' => [
'sloId' => '123e4567-e89b-12d3-a456-426614174000'
]
],
'tracingImmediate' => [
'notificationPayloadFilter' => [
'obj.field'
],
'tracingFilter' => [
'simpleFilter' => [
'latencyThresholdMs' => '1000',
'tracingLabelFilters' => [
'applicationName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
],
'operationName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
],
'serviceName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
],
'spanFields' => [
[
'filterType' => [
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
],
'key' => 'span.field.key'
]
],
'subsystemName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
]
]
]
]
],
'tracingThreshold' => [
'notificationPayloadFilter' => [
'obj.field'
],
'rules' => [
[
'condition' => [
'conditionType' => 'TRACING_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
'spanAmount' => 100,
'timeWindow' => [
'tracingTimeWindowValue' => 'TRACING_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED'
]
]
]
],
'tracingFilter' => [
'simpleFilter' => [
'latencyThresholdMs' => '1000',
'tracingLabelFilters' => [
'applicationName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
],
'operationName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
],
'serviceName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
],
'spanFields' => [
[
'filterType' => [
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
],
'key' => 'span.field.key'
]
],
'subsystemName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
]
]
]
]
],
'type' => 'ALERT_DEF_TYPE_METRIC_THRESHOLD'
],
'accessPolicy' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.coralogix.com/mgmt/openapi/5/alerts/alerts/v3/all/create"
payload := strings.NewReader("{\n \"alertDefsToCreate\": [\n {\n \"alertDefProperties\": {\n \"logsImmediate\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ]\n },\n \"activeOn\": {\n \"dayOfWeek\": [\n \"DAY_OF_WEEK_MONDAY_OR_UNSPECIFIED\",\n \"DAY_OF_WEEK_TUESDAY\"\n ],\n \"endTime\": {\n \"hours\": 14,\n \"minutes\": 30\n },\n \"startTime\": {\n \"hours\": 14,\n \"minutes\": 30\n }\n },\n \"analyticsImmediate\": {\n \"dataprimeQuery\": {\n \"query\": \"source logs | filter severity == 'error' | count_agg_key by applicationName\"\n },\n \"evaluationDelayMs\": 300000,\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"timeframeMinutes\": 60,\n \"useRowsAsPermutations\": false\n },\n \"analyticsThreshold\": {\n \"dataprimeQuery\": {\n \"query\": \"source logs | filter severity == 'error' | count_agg_key by applicationName\"\n },\n \"evaluationDelayMs\": 300000,\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"operator\": \"ANALYTICS_THRESHOLD_OPERATOR_MORE_THAN_OR_UNSPECIFIED\",\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 100\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"targetColumn\": \"error_count\",\n \"timeframeMinutes\": 60,\n \"useRowsAsPermutations\": true\n },\n \"dataSources\": [\n {\n \"dataSet\": \"<string>\",\n \"dataSpace\": \"<string>\"\n }\n ],\n \"deleted\": false,\n \"description\": \"Alert description\",\n \"enabled\": true,\n \"entityLabels\": {},\n \"flow\": {\n \"enforceSuppression\": true,\n \"stages\": [\n {\n \"flowStagesGroups\": {\n \"groups\": [\n {\n \"alertDefs\": [\n {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"not\": true\n }\n ],\n \"alertsOp\": \"ALERTS_OP_OR\",\n \"nextOp\": \"NEXT_OP_OR\"\n }\n ]\n },\n \"timeframeMs\": \"<string>\",\n \"timeframeType\": \"TIMEFRAME_TYPE_UP_TO\"\n }\n ]\n },\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"incidentsSettings\": {\n \"minutes\": 30,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n },\n \"logsAnomaly\": {\n \"anomalyAlertSettings\": {\n \"percentageOfDeviation\": 1\n },\n \"evaluationDelayMs\": 60000,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_ANOMALY_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"minimumThreshold\": 10,\n \"timeWindow\": {\n \"logsTimeWindowSpecificValue\": \"LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n }\n }\n ]\n },\n \"logsNewValue\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"keypathToTrack\": \"metadata.field\",\n \"timeWindow\": {\n \"logsNewValueTimeWindowSpecificValue\": \"LOGS_NEW_VALUE_TIME_WINDOW_VALUE_HOURS_12_OR_UNSPECIFIED\"\n }\n }\n }\n ]\n },\n \"logsRatioThreshold\": {\n \"denominator\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"denominatorAlias\": \"denominator_alias\",\n \"evaluationDelayMs\": 60000,\n \"groupByFor\": \"LOGS_RATIO_GROUP_BY_FOR_NUMERATOR_ONLY\",\n \"ignoreInfinity\": true,\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"numerator\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"numeratorAlias\": \"numerator_alias\",\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_RATIO_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 10,\n \"timeWindow\": 10\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 100,\n \"timeWindow\": {\n \"logsTimeWindowSpecificValue\": \"LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsTimeRelativeThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"ignoreInfinity\": true,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"comparedTo\": \"LOGS_TIME_RELATIVE_COMPARED_TO_YESTERDAY\",\n \"conditionType\": \"LOGS_TIME_RELATIVE_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsUniqueCount\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"maxUniqueCountPerGroupByKey\": \"100\",\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"maxUniqueCount\": \"100\",\n \"timeWindow\": {\n \"logsUniqueValueTimeWindowSpecificValue\": \"LOGS_UNIQUE_VALUE_TIME_WINDOW_VALUE_HOURS_12\"\n }\n }\n }\n ],\n \"uniqueCountKeypath\": \"obj.field\"\n },\n \"metricAnomaly\": {\n \"anomalyAlertSettings\": {\n \"percentageOfDeviation\": 1\n },\n \"evaluationDelayMs\": 60000,\n \"metricFilter\": {\n \"promql\": \"avg_over_time(metric_name[5m]) > 10\"\n },\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"METRIC_ANOMALY_CONDITION_TYPE_LESS_THAN_USUAL\",\n \"forOverPct\": 20,\n \"minNonNullValuesPct\": 10,\n \"ofTheLast\": {\n \"metricTimeWindowSpecificValue\": \"METRIC_TIME_WINDOW_VALUE_MINUTES_5\",\n \"metricTimeWindowDynamicDuration\": \"1h30m\"\n },\n \"threshold\": 10\n }\n }\n ]\n },\n \"metricThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"metricFilter\": {\n \"promql\": \"avg_over_time(metric_name[5m]) > 10\"\n },\n \"missingValues\": {\n \"replaceWithZero\": true,\n \"minNonNullValuesPct\": 80\n },\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"METRIC_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_EQUALS\",\n \"forOverPct\": 80,\n \"ofTheLast\": {\n \"metricTimeWindowSpecificValue\": \"METRIC_TIME_WINDOW_VALUE_MINUTES_5\",\n \"metricTimeWindowDynamicDuration\": \"1h30m\"\n },\n \"threshold\": 100\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"name\": \"My Alert\",\n \"notificationGroup\": {\n \"destinations\": [\n {\n \"connectorId\": \"connector_id_example\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\",\n \"presetId\": \"preset_id_example\",\n \"resolvedRouteOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n },\n \"retriggeringPeriodMinutes\": 600,\n \"triggeredRoutingOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n }\n }\n ],\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"router\": {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED\"\n },\n \"webhooks\": [\n {\n \"integration\": {\n \"integrationId\": 123,\n \"recipients\": {\n \"emails\": [\n \"mail@gmail.com\"\n ]\n }\n },\n \"minutes\": 15,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n }\n ]\n },\n \"notificationGroupExcess\": [\n {\n \"destinations\": [\n {\n \"connectorId\": \"connector_id_example\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\",\n \"presetId\": \"preset_id_example\",\n \"resolvedRouteOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n },\n \"retriggeringPeriodMinutes\": 600,\n \"triggeredRoutingOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n }\n }\n ],\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"router\": {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED\"\n },\n \"webhooks\": [\n {\n \"integration\": {\n \"integrationId\": 123,\n \"recipients\": {\n \"emails\": [\n \"mail@gmail.com\"\n ]\n }\n },\n \"minutes\": 15,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n }\n ]\n }\n ],\n \"phantomMode\": false,\n \"priority\": \"ALERT_DEF_PRIORITY_P4\",\n \"sloThreshold\": {\n \"errorBudget\": {\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ]\n },\n \"burnRate\": {\n \"dual\": {\n \"timeDuration\": {\n \"duration\": \"24\",\n \"unit\": \"DURATION_UNIT_HOURS\"\n }\n },\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"single\": {\n \"timeDuration\": {\n \"duration\": \"24\",\n \"unit\": \"DURATION_UNIT_HOURS\"\n }\n }\n },\n \"sloDefinition\": {\n \"sloId\": \"123e4567-e89b-12d3-a456-426614174000\"\n }\n },\n \"tracingImmediate\": {\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"tracingFilter\": {\n \"simpleFilter\": {\n \"latencyThresholdMs\": \"1000\",\n \"tracingLabelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"operationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"serviceName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"spanFields\": [\n {\n \"filterType\": {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n },\n \"key\": \"span.field.key\"\n }\n ],\n \"subsystemName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ]\n }\n }\n }\n },\n \"tracingThreshold\": {\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"TRACING_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"spanAmount\": 100,\n \"timeWindow\": {\n \"tracingTimeWindowValue\": \"TRACING_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n }\n }\n ],\n \"tracingFilter\": {\n \"simpleFilter\": {\n \"latencyThresholdMs\": \"1000\",\n \"tracingLabelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"operationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"serviceName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"spanFields\": [\n {\n \"filterType\": {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n },\n \"key\": \"span.field.key\"\n }\n ],\n \"subsystemName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ]\n }\n }\n }\n },\n \"type\": \"ALERT_DEF_TYPE_METRIC_THRESHOLD\"\n },\n \"accessPolicy\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.coralogix.com/mgmt/openapi/5/alerts/alerts/v3/all/create")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"alertDefsToCreate\": [\n {\n \"alertDefProperties\": {\n \"logsImmediate\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ]\n },\n \"activeOn\": {\n \"dayOfWeek\": [\n \"DAY_OF_WEEK_MONDAY_OR_UNSPECIFIED\",\n \"DAY_OF_WEEK_TUESDAY\"\n ],\n \"endTime\": {\n \"hours\": 14,\n \"minutes\": 30\n },\n \"startTime\": {\n \"hours\": 14,\n \"minutes\": 30\n }\n },\n \"analyticsImmediate\": {\n \"dataprimeQuery\": {\n \"query\": \"source logs | filter severity == 'error' | count_agg_key by applicationName\"\n },\n \"evaluationDelayMs\": 300000,\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"timeframeMinutes\": 60,\n \"useRowsAsPermutations\": false\n },\n \"analyticsThreshold\": {\n \"dataprimeQuery\": {\n \"query\": \"source logs | filter severity == 'error' | count_agg_key by applicationName\"\n },\n \"evaluationDelayMs\": 300000,\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"operator\": \"ANALYTICS_THRESHOLD_OPERATOR_MORE_THAN_OR_UNSPECIFIED\",\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 100\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"targetColumn\": \"error_count\",\n \"timeframeMinutes\": 60,\n \"useRowsAsPermutations\": true\n },\n \"dataSources\": [\n {\n \"dataSet\": \"<string>\",\n \"dataSpace\": \"<string>\"\n }\n ],\n \"deleted\": false,\n \"description\": \"Alert description\",\n \"enabled\": true,\n \"entityLabels\": {},\n \"flow\": {\n \"enforceSuppression\": true,\n \"stages\": [\n {\n \"flowStagesGroups\": {\n \"groups\": [\n {\n \"alertDefs\": [\n {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"not\": true\n }\n ],\n \"alertsOp\": \"ALERTS_OP_OR\",\n \"nextOp\": \"NEXT_OP_OR\"\n }\n ]\n },\n \"timeframeMs\": \"<string>\",\n \"timeframeType\": \"TIMEFRAME_TYPE_UP_TO\"\n }\n ]\n },\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"incidentsSettings\": {\n \"minutes\": 30,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n },\n \"logsAnomaly\": {\n \"anomalyAlertSettings\": {\n \"percentageOfDeviation\": 1\n },\n \"evaluationDelayMs\": 60000,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_ANOMALY_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"minimumThreshold\": 10,\n \"timeWindow\": {\n \"logsTimeWindowSpecificValue\": \"LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n }\n }\n ]\n },\n \"logsNewValue\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"keypathToTrack\": \"metadata.field\",\n \"timeWindow\": {\n \"logsNewValueTimeWindowSpecificValue\": \"LOGS_NEW_VALUE_TIME_WINDOW_VALUE_HOURS_12_OR_UNSPECIFIED\"\n }\n }\n }\n ]\n },\n \"logsRatioThreshold\": {\n \"denominator\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"denominatorAlias\": \"denominator_alias\",\n \"evaluationDelayMs\": 60000,\n \"groupByFor\": \"LOGS_RATIO_GROUP_BY_FOR_NUMERATOR_ONLY\",\n \"ignoreInfinity\": true,\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"numerator\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"numeratorAlias\": \"numerator_alias\",\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_RATIO_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 10,\n \"timeWindow\": 10\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 100,\n \"timeWindow\": {\n \"logsTimeWindowSpecificValue\": \"LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsTimeRelativeThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"ignoreInfinity\": true,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"comparedTo\": \"LOGS_TIME_RELATIVE_COMPARED_TO_YESTERDAY\",\n \"conditionType\": \"LOGS_TIME_RELATIVE_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsUniqueCount\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"maxUniqueCountPerGroupByKey\": \"100\",\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"maxUniqueCount\": \"100\",\n \"timeWindow\": {\n \"logsUniqueValueTimeWindowSpecificValue\": \"LOGS_UNIQUE_VALUE_TIME_WINDOW_VALUE_HOURS_12\"\n }\n }\n }\n ],\n \"uniqueCountKeypath\": \"obj.field\"\n },\n \"metricAnomaly\": {\n \"anomalyAlertSettings\": {\n \"percentageOfDeviation\": 1\n },\n \"evaluationDelayMs\": 60000,\n \"metricFilter\": {\n \"promql\": \"avg_over_time(metric_name[5m]) > 10\"\n },\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"METRIC_ANOMALY_CONDITION_TYPE_LESS_THAN_USUAL\",\n \"forOverPct\": 20,\n \"minNonNullValuesPct\": 10,\n \"ofTheLast\": {\n \"metricTimeWindowSpecificValue\": \"METRIC_TIME_WINDOW_VALUE_MINUTES_5\",\n \"metricTimeWindowDynamicDuration\": \"1h30m\"\n },\n \"threshold\": 10\n }\n }\n ]\n },\n \"metricThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"metricFilter\": {\n \"promql\": \"avg_over_time(metric_name[5m]) > 10\"\n },\n \"missingValues\": {\n \"replaceWithZero\": true,\n \"minNonNullValuesPct\": 80\n },\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"METRIC_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_EQUALS\",\n \"forOverPct\": 80,\n \"ofTheLast\": {\n \"metricTimeWindowSpecificValue\": \"METRIC_TIME_WINDOW_VALUE_MINUTES_5\",\n \"metricTimeWindowDynamicDuration\": \"1h30m\"\n },\n \"threshold\": 100\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"name\": \"My Alert\",\n \"notificationGroup\": {\n \"destinations\": [\n {\n \"connectorId\": \"connector_id_example\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\",\n \"presetId\": \"preset_id_example\",\n \"resolvedRouteOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n },\n \"retriggeringPeriodMinutes\": 600,\n \"triggeredRoutingOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n }\n }\n ],\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"router\": {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED\"\n },\n \"webhooks\": [\n {\n \"integration\": {\n \"integrationId\": 123,\n \"recipients\": {\n \"emails\": [\n \"mail@gmail.com\"\n ]\n }\n },\n \"minutes\": 15,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n }\n ]\n },\n \"notificationGroupExcess\": [\n {\n \"destinations\": [\n {\n \"connectorId\": \"connector_id_example\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\",\n \"presetId\": \"preset_id_example\",\n \"resolvedRouteOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n },\n \"retriggeringPeriodMinutes\": 600,\n \"triggeredRoutingOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n }\n }\n ],\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"router\": {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED\"\n },\n \"webhooks\": [\n {\n \"integration\": {\n \"integrationId\": 123,\n \"recipients\": {\n \"emails\": [\n \"mail@gmail.com\"\n ]\n }\n },\n \"minutes\": 15,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n }\n ]\n }\n ],\n \"phantomMode\": false,\n \"priority\": \"ALERT_DEF_PRIORITY_P4\",\n \"sloThreshold\": {\n \"errorBudget\": {\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ]\n },\n \"burnRate\": {\n \"dual\": {\n \"timeDuration\": {\n \"duration\": \"24\",\n \"unit\": \"DURATION_UNIT_HOURS\"\n }\n },\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"single\": {\n \"timeDuration\": {\n \"duration\": \"24\",\n \"unit\": \"DURATION_UNIT_HOURS\"\n }\n }\n },\n \"sloDefinition\": {\n \"sloId\": \"123e4567-e89b-12d3-a456-426614174000\"\n }\n },\n \"tracingImmediate\": {\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"tracingFilter\": {\n \"simpleFilter\": {\n \"latencyThresholdMs\": \"1000\",\n \"tracingLabelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"operationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"serviceName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"spanFields\": [\n {\n \"filterType\": {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n },\n \"key\": \"span.field.key\"\n }\n ],\n \"subsystemName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ]\n }\n }\n }\n },\n \"tracingThreshold\": {\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"TRACING_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"spanAmount\": 100,\n \"timeWindow\": {\n \"tracingTimeWindowValue\": \"TRACING_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n }\n }\n ],\n \"tracingFilter\": {\n \"simpleFilter\": {\n \"latencyThresholdMs\": \"1000\",\n \"tracingLabelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"operationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"serviceName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"spanFields\": [\n {\n \"filterType\": {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n },\n \"key\": \"span.field.key\"\n }\n ],\n \"subsystemName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ]\n }\n }\n }\n },\n \"type\": \"ALERT_DEF_TYPE_METRIC_THRESHOLD\"\n },\n \"accessPolicy\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.coralogix.com/mgmt/openapi/5/alerts/alerts/v3/all/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"alertDefsToCreate\": [\n {\n \"alertDefProperties\": {\n \"logsImmediate\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ]\n },\n \"activeOn\": {\n \"dayOfWeek\": [\n \"DAY_OF_WEEK_MONDAY_OR_UNSPECIFIED\",\n \"DAY_OF_WEEK_TUESDAY\"\n ],\n \"endTime\": {\n \"hours\": 14,\n \"minutes\": 30\n },\n \"startTime\": {\n \"hours\": 14,\n \"minutes\": 30\n }\n },\n \"analyticsImmediate\": {\n \"dataprimeQuery\": {\n \"query\": \"source logs | filter severity == 'error' | count_agg_key by applicationName\"\n },\n \"evaluationDelayMs\": 300000,\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"timeframeMinutes\": 60,\n \"useRowsAsPermutations\": false\n },\n \"analyticsThreshold\": {\n \"dataprimeQuery\": {\n \"query\": \"source logs | filter severity == 'error' | count_agg_key by applicationName\"\n },\n \"evaluationDelayMs\": 300000,\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"operator\": \"ANALYTICS_THRESHOLD_OPERATOR_MORE_THAN_OR_UNSPECIFIED\",\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 100\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"targetColumn\": \"error_count\",\n \"timeframeMinutes\": 60,\n \"useRowsAsPermutations\": true\n },\n \"dataSources\": [\n {\n \"dataSet\": \"<string>\",\n \"dataSpace\": \"<string>\"\n }\n ],\n \"deleted\": false,\n \"description\": \"Alert description\",\n \"enabled\": true,\n \"entityLabels\": {},\n \"flow\": {\n \"enforceSuppression\": true,\n \"stages\": [\n {\n \"flowStagesGroups\": {\n \"groups\": [\n {\n \"alertDefs\": [\n {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"not\": true\n }\n ],\n \"alertsOp\": \"ALERTS_OP_OR\",\n \"nextOp\": \"NEXT_OP_OR\"\n }\n ]\n },\n \"timeframeMs\": \"<string>\",\n \"timeframeType\": \"TIMEFRAME_TYPE_UP_TO\"\n }\n ]\n },\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"incidentsSettings\": {\n \"minutes\": 30,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n },\n \"logsAnomaly\": {\n \"anomalyAlertSettings\": {\n \"percentageOfDeviation\": 1\n },\n \"evaluationDelayMs\": 60000,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_ANOMALY_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"minimumThreshold\": 10,\n \"timeWindow\": {\n \"logsTimeWindowSpecificValue\": \"LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n }\n }\n ]\n },\n \"logsNewValue\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"keypathToTrack\": \"metadata.field\",\n \"timeWindow\": {\n \"logsNewValueTimeWindowSpecificValue\": \"LOGS_NEW_VALUE_TIME_WINDOW_VALUE_HOURS_12_OR_UNSPECIFIED\"\n }\n }\n }\n ]\n },\n \"logsRatioThreshold\": {\n \"denominator\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"denominatorAlias\": \"denominator_alias\",\n \"evaluationDelayMs\": 60000,\n \"groupByFor\": \"LOGS_RATIO_GROUP_BY_FOR_NUMERATOR_ONLY\",\n \"ignoreInfinity\": true,\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"numerator\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"numeratorAlias\": \"numerator_alias\",\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_RATIO_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 10,\n \"timeWindow\": 10\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 100,\n \"timeWindow\": {\n \"logsTimeWindowSpecificValue\": \"LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsTimeRelativeThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"ignoreInfinity\": true,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"comparedTo\": \"LOGS_TIME_RELATIVE_COMPARED_TO_YESTERDAY\",\n \"conditionType\": \"LOGS_TIME_RELATIVE_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsUniqueCount\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"maxUniqueCountPerGroupByKey\": \"100\",\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"maxUniqueCount\": \"100\",\n \"timeWindow\": {\n \"logsUniqueValueTimeWindowSpecificValue\": \"LOGS_UNIQUE_VALUE_TIME_WINDOW_VALUE_HOURS_12\"\n }\n }\n }\n ],\n \"uniqueCountKeypath\": \"obj.field\"\n },\n \"metricAnomaly\": {\n \"anomalyAlertSettings\": {\n \"percentageOfDeviation\": 1\n },\n \"evaluationDelayMs\": 60000,\n \"metricFilter\": {\n \"promql\": \"avg_over_time(metric_name[5m]) > 10\"\n },\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"METRIC_ANOMALY_CONDITION_TYPE_LESS_THAN_USUAL\",\n \"forOverPct\": 20,\n \"minNonNullValuesPct\": 10,\n \"ofTheLast\": {\n \"metricTimeWindowSpecificValue\": \"METRIC_TIME_WINDOW_VALUE_MINUTES_5\",\n \"metricTimeWindowDynamicDuration\": \"1h30m\"\n },\n \"threshold\": 10\n }\n }\n ]\n },\n \"metricThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"metricFilter\": {\n \"promql\": \"avg_over_time(metric_name[5m]) > 10\"\n },\n \"missingValues\": {\n \"replaceWithZero\": true,\n \"minNonNullValuesPct\": 80\n },\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"METRIC_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_EQUALS\",\n \"forOverPct\": 80,\n \"ofTheLast\": {\n \"metricTimeWindowSpecificValue\": \"METRIC_TIME_WINDOW_VALUE_MINUTES_5\",\n \"metricTimeWindowDynamicDuration\": \"1h30m\"\n },\n \"threshold\": 100\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"name\": \"My Alert\",\n \"notificationGroup\": {\n \"destinations\": [\n {\n \"connectorId\": \"connector_id_example\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\",\n \"presetId\": \"preset_id_example\",\n \"resolvedRouteOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n },\n \"retriggeringPeriodMinutes\": 600,\n \"triggeredRoutingOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n }\n }\n ],\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"router\": {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED\"\n },\n \"webhooks\": [\n {\n \"integration\": {\n \"integrationId\": 123,\n \"recipients\": {\n \"emails\": [\n \"mail@gmail.com\"\n ]\n }\n },\n \"minutes\": 15,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n }\n ]\n },\n \"notificationGroupExcess\": [\n {\n \"destinations\": [\n {\n \"connectorId\": \"connector_id_example\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\",\n \"presetId\": \"preset_id_example\",\n \"resolvedRouteOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n },\n \"retriggeringPeriodMinutes\": 600,\n \"triggeredRoutingOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n }\n }\n ],\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"router\": {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED\"\n },\n \"webhooks\": [\n {\n \"integration\": {\n \"integrationId\": 123,\n \"recipients\": {\n \"emails\": [\n \"mail@gmail.com\"\n ]\n }\n },\n \"minutes\": 15,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n }\n ]\n }\n ],\n \"phantomMode\": false,\n \"priority\": \"ALERT_DEF_PRIORITY_P4\",\n \"sloThreshold\": {\n \"errorBudget\": {\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ]\n },\n \"burnRate\": {\n \"dual\": {\n \"timeDuration\": {\n \"duration\": \"24\",\n \"unit\": \"DURATION_UNIT_HOURS\"\n }\n },\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"single\": {\n \"timeDuration\": {\n \"duration\": \"24\",\n \"unit\": \"DURATION_UNIT_HOURS\"\n }\n }\n },\n \"sloDefinition\": {\n \"sloId\": \"123e4567-e89b-12d3-a456-426614174000\"\n }\n },\n \"tracingImmediate\": {\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"tracingFilter\": {\n \"simpleFilter\": {\n \"latencyThresholdMs\": \"1000\",\n \"tracingLabelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"operationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"serviceName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"spanFields\": [\n {\n \"filterType\": {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n },\n \"key\": \"span.field.key\"\n }\n ],\n \"subsystemName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ]\n }\n }\n }\n },\n \"tracingThreshold\": {\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"TRACING_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"spanAmount\": 100,\n \"timeWindow\": {\n \"tracingTimeWindowValue\": \"TRACING_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n }\n }\n ],\n \"tracingFilter\": {\n \"simpleFilter\": {\n \"latencyThresholdMs\": \"1000\",\n \"tracingLabelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"operationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"serviceName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"spanFields\": [\n {\n \"filterType\": {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n },\n \"key\": \"span.field.key\"\n }\n ],\n \"subsystemName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ]\n }\n }\n }\n },\n \"type\": \"ALERT_DEF_TYPE_METRIC_THRESHOLD\"\n },\n \"accessPolicy\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"alertDefs": [
{
"alertDefProperties": {
"description": "Fires when the error rate exceeds the threshold.",
"enabled": true,
"name": "High error rate",
"priority": "ALERT_DEF_PRIORITY_P2",
"type": "ALERT_DEF_TYPE_LOGS_THRESHOLD"
},
"alertVersionId": "223e4567-e89b-12d3-a456-426614174000",
"createdTime": "2026-07-01T08:30:00.000Z",
"id": "123e4567-e89b-12d3-a456-426614174000",
"updatedTime": "2026-07-01T08:30:00.000Z"
}
],
"failedToCreateAlertDefs": [
{
"index": 1,
"reason": "Alert definition name must not be empty."
}
]
}{
"code": 349,
"message": "<string>"
}{
"code": 349,
"message": "<string>"
}{
"code": 349,
"message": "<string>"
}Bulk create alert definitions
Creates multiple alert definitions in a single request. The operation is best-effort - definitions that fail to be created are reported in the response and do not prevent creation of the others. Limited to 100 alert definitions per request.
Requires the following permissions:
alerts:UpdateConfig
curl --request POST \
--url https://api.coralogix.com/mgmt/openapi/5/alerts/alerts/v3/all/create \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"alertDefsToCreate": [
{
"alertDefProperties": {
"logsImmediate": {
"logsFilter": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"notificationPayloadFilter": [
"obj.field"
]
},
"activeOn": {
"dayOfWeek": [
"DAY_OF_WEEK_MONDAY_OR_UNSPECIFIED",
"DAY_OF_WEEK_TUESDAY"
],
"endTime": {
"hours": 14,
"minutes": 30
},
"startTime": {
"hours": 14,
"minutes": 30
}
},
"analyticsImmediate": {
"dataprimeQuery": {
"query": "source logs | filter severity == 'error' | count_agg_key by applicationName"
},
"evaluationDelayMs": 300000,
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"timeframeMinutes": 60,
"useRowsAsPermutations": false
},
"analyticsThreshold": {
"dataprimeQuery": {
"query": "source logs | filter severity == 'error' | count_agg_key by applicationName"
},
"evaluationDelayMs": 300000,
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"operator": "ANALYTICS_THRESHOLD_OPERATOR_MORE_THAN_OR_UNSPECIFIED",
"rules": [
{
"condition": {
"threshold": 100
},
"override": {
"priority": "ALERT_DEF_PRIORITY_P3"
}
}
],
"targetColumn": "error_count",
"timeframeMinutes": 60,
"useRowsAsPermutations": true
},
"dataSources": [
{
"dataSet": "<string>",
"dataSpace": "<string>"
}
],
"deleted": false,
"description": "Alert description",
"enabled": true,
"entityLabels": {},
"flow": {
"enforceSuppression": true,
"stages": [
{
"flowStagesGroups": {
"groups": [
{
"alertDefs": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"not": true
}
],
"alertsOp": "ALERTS_OP_OR",
"nextOp": "NEXT_OP_OR"
}
]
},
"timeframeMs": "<string>",
"timeframeType": "TIMEFRAME_TYPE_UP_TO"
}
]
},
"groupByKeys": [
"key1",
"key2"
],
"incidentsSettings": {
"minutes": 30,
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED"
},
"logsAnomaly": {
"anomalyAlertSettings": {
"percentageOfDeviation": 1
},
"evaluationDelayMs": 60000,
"logsFilter": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"notificationPayloadFilter": [
"obj.field"
],
"rules": [
{
"condition": {
"conditionType": "LOGS_ANOMALY_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"minimumThreshold": 10,
"timeWindow": {
"logsTimeWindowSpecificValue": "LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED"
}
}
}
]
},
"logsNewValue": {
"logsFilter": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"notificationPayloadFilter": [
"obj.field"
],
"rules": [
{
"condition": {
"keypathToTrack": "metadata.field",
"timeWindow": {
"logsNewValueTimeWindowSpecificValue": "LOGS_NEW_VALUE_TIME_WINDOW_VALUE_HOURS_12_OR_UNSPECIFIED"
}
}
}
]
},
"logsRatioThreshold": {
"denominator": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"denominatorAlias": "denominator_alias",
"evaluationDelayMs": 60000,
"groupByFor": "LOGS_RATIO_GROUP_BY_FOR_NUMERATOR_ONLY",
"ignoreInfinity": true,
"notificationPayloadFilter": [
"obj.field"
],
"numerator": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"numeratorAlias": "numerator_alias",
"rules": [
{
"condition": {
"conditionType": "LOGS_RATIO_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"threshold": 10,
"timeWindow": 10
},
"override": {
"priority": "ALERT_DEF_PRIORITY_P3"
}
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": true
}
},
"logsThreshold": {
"evaluationDelayMs": 60000,
"logsFilter": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"notificationPayloadFilter": [
"obj.field"
],
"rules": [
{
"condition": {
"conditionType": "LOGS_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"threshold": 100,
"timeWindow": {
"logsTimeWindowSpecificValue": "LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED"
}
},
"override": {
"priority": "ALERT_DEF_PRIORITY_P3"
}
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": true
}
},
"logsTimeRelativeThreshold": {
"evaluationDelayMs": 60000,
"ignoreInfinity": true,
"logsFilter": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"notificationPayloadFilter": [
"obj.field"
],
"rules": [
{
"condition": {
"comparedTo": "LOGS_TIME_RELATIVE_COMPARED_TO_YESTERDAY",
"conditionType": "LOGS_TIME_RELATIVE_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"threshold": 1
},
"override": {
"priority": "ALERT_DEF_PRIORITY_P3"
}
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": true
}
},
"logsUniqueCount": {
"logsFilter": {
"simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
}
},
"maxUniqueCountPerGroupByKey": "100",
"notificationPayloadFilter": [
"obj.field"
],
"rules": [
{
"condition": {
"maxUniqueCount": "100",
"timeWindow": {
"logsUniqueValueTimeWindowSpecificValue": "LOGS_UNIQUE_VALUE_TIME_WINDOW_VALUE_HOURS_12"
}
}
}
],
"uniqueCountKeypath": "obj.field"
},
"metricAnomaly": {
"anomalyAlertSettings": {
"percentageOfDeviation": 1
},
"evaluationDelayMs": 60000,
"metricFilter": {
"promql": "avg_over_time(metric_name[5m]) > 10"
},
"rules": [
{
"condition": {
"conditionType": "METRIC_ANOMALY_CONDITION_TYPE_LESS_THAN_USUAL",
"forOverPct": 20,
"minNonNullValuesPct": 10,
"ofTheLast": {
"metricTimeWindowSpecificValue": "METRIC_TIME_WINDOW_VALUE_MINUTES_5",
"metricTimeWindowDynamicDuration": "1h30m"
},
"threshold": 10
}
}
]
},
"metricThreshold": {
"evaluationDelayMs": 60000,
"metricFilter": {
"promql": "avg_over_time(metric_name[5m]) > 10"
},
"missingValues": {
"replaceWithZero": true,
"minNonNullValuesPct": 80
},
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"rules": [
{
"condition": {
"conditionType": "METRIC_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_EQUALS",
"forOverPct": 80,
"ofTheLast": {
"metricTimeWindowSpecificValue": "METRIC_TIME_WINDOW_VALUE_MINUTES_5",
"metricTimeWindowDynamicDuration": "1h30m"
},
"threshold": 100
},
"override": {
"priority": "ALERT_DEF_PRIORITY_P3"
}
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": true
}
},
"name": "My Alert",
"notificationGroup": {
"destinations": [
{
"connectorId": "connector_id_example",
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED",
"presetId": "preset_id_example",
"resolvedRouteOverrides": {
"configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
}
},
"retriggeringPeriodMinutes": 600,
"triggeredRoutingOverrides": {
"configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
}
}
}
],
"groupByKeys": [
"key1",
"key2"
],
"router": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"notifyOn": "NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED"
},
"webhooks": [
{
"integration": {
"integrationId": 123,
"recipients": {
"emails": [
"mail@gmail.com"
]
}
},
"minutes": 15,
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED"
}
]
},
"notificationGroupExcess": [
{
"destinations": [
{
"connectorId": "connector_id_example",
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED",
"presetId": "preset_id_example",
"resolvedRouteOverrides": {
"configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
}
},
"retriggeringPeriodMinutes": 600,
"triggeredRoutingOverrides": {
"configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
}
}
}
],
"groupByKeys": [
"key1",
"key2"
],
"router": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"notifyOn": "NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED"
},
"webhooks": [
{
"integration": {
"integrationId": 123,
"recipients": {
"emails": [
"mail@gmail.com"
]
}
},
"minutes": 15,
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED"
}
]
}
],
"phantomMode": false,
"priority": "ALERT_DEF_PRIORITY_P4",
"sloThreshold": {
"errorBudget": {
"rules": [
{
"condition": {
"threshold": 1
},
"override": {
"priority": "ALERT_DEF_PRIORITY_P3"
}
}
]
},
"burnRate": {
"dual": {
"timeDuration": {
"duration": "24",
"unit": "DURATION_UNIT_HOURS"
}
},
"rules": [
{
"condition": {
"threshold": 1
},
"override": {
"priority": "ALERT_DEF_PRIORITY_P3"
}
}
],
"single": {
"timeDuration": {
"duration": "24",
"unit": "DURATION_UNIT_HOURS"
}
}
},
"sloDefinition": {
"sloId": "123e4567-e89b-12d3-a456-426614174000"
}
},
"tracingImmediate": {
"notificationPayloadFilter": [
"obj.field"
],
"tracingFilter": {
"simpleFilter": {
"latencyThresholdMs": "1000",
"tracingLabelFilters": {
"applicationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
],
"operationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
],
"serviceName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
],
"spanFields": [
{
"filterType": {
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
},
"key": "span.field.key"
}
],
"subsystemName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
]
}
}
}
},
"tracingThreshold": {
"notificationPayloadFilter": [
"obj.field"
],
"rules": [
{
"condition": {
"conditionType": "TRACING_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"spanAmount": 100,
"timeWindow": {
"tracingTimeWindowValue": "TRACING_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED"
}
}
}
],
"tracingFilter": {
"simpleFilter": {
"latencyThresholdMs": "1000",
"tracingLabelFilters": {
"applicationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
],
"operationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
],
"serviceName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
],
"spanFields": [
{
"filterType": {
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
},
"key": "span.field.key"
}
],
"subsystemName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": [
"value1",
"value2"
]
}
]
}
}
}
},
"type": "ALERT_DEF_TYPE_METRIC_THRESHOLD"
},
"accessPolicy": "<string>"
}
]
}
EOFimport requests
url = "https://api.coralogix.com/mgmt/openapi/5/alerts/alerts/v3/all/create"
payload = { "alertDefsToCreate": [
{
"alertDefProperties": {
"logsImmediate": {
"logsFilter": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"notificationPayloadFilter": ["obj.field"]
},
"activeOn": {
"dayOfWeek": ["DAY_OF_WEEK_MONDAY_OR_UNSPECIFIED", "DAY_OF_WEEK_TUESDAY"],
"endTime": {
"hours": 14,
"minutes": 30
},
"startTime": {
"hours": 14,
"minutes": 30
}
},
"analyticsImmediate": {
"dataprimeQuery": { "query": "source logs | filter severity == 'error' | count_agg_key by applicationName" },
"evaluationDelayMs": 300000,
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"timeframeMinutes": 60,
"useRowsAsPermutations": False
},
"analyticsThreshold": {
"dataprimeQuery": { "query": "source logs | filter severity == 'error' | count_agg_key by applicationName" },
"evaluationDelayMs": 300000,
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"operator": "ANALYTICS_THRESHOLD_OPERATOR_MORE_THAN_OR_UNSPECIFIED",
"rules": [
{
"condition": { "threshold": 100 },
"override": { "priority": "ALERT_DEF_PRIORITY_P3" }
}
],
"targetColumn": "error_count",
"timeframeMinutes": 60,
"useRowsAsPermutations": True
},
"dataSources": [
{
"dataSet": "<string>",
"dataSpace": "<string>"
}
],
"deleted": False,
"description": "Alert description",
"enabled": True,
"entityLabels": {},
"flow": {
"enforceSuppression": True,
"stages": [
{
"flowStagesGroups": { "groups": [
{
"alertDefs": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"not": True
}
],
"alertsOp": "ALERTS_OP_OR",
"nextOp": "NEXT_OP_OR"
}
] },
"timeframeMs": "<string>",
"timeframeType": "TIMEFRAME_TYPE_UP_TO"
}
]
},
"groupByKeys": ["key1", "key2"],
"incidentsSettings": {
"minutes": 30,
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED"
},
"logsAnomaly": {
"anomalyAlertSettings": { "percentageOfDeviation": 1 },
"evaluationDelayMs": 60000,
"logsFilter": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"notificationPayloadFilter": ["obj.field"],
"rules": [{ "condition": {
"conditionType": "LOGS_ANOMALY_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"minimumThreshold": 10,
"timeWindow": { "logsTimeWindowSpecificValue": "LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED" }
} }]
},
"logsNewValue": {
"logsFilter": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"notificationPayloadFilter": ["obj.field"],
"rules": [{ "condition": {
"keypathToTrack": "metadata.field",
"timeWindow": { "logsNewValueTimeWindowSpecificValue": "LOGS_NEW_VALUE_TIME_WINDOW_VALUE_HOURS_12_OR_UNSPECIFIED" }
} }]
},
"logsRatioThreshold": {
"denominator": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"denominatorAlias": "denominator_alias",
"evaluationDelayMs": 60000,
"groupByFor": "LOGS_RATIO_GROUP_BY_FOR_NUMERATOR_ONLY",
"ignoreInfinity": True,
"notificationPayloadFilter": ["obj.field"],
"numerator": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"numeratorAlias": "numerator_alias",
"rules": [
{
"condition": {
"conditionType": "LOGS_RATIO_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"threshold": 10,
"timeWindow": 10
},
"override": { "priority": "ALERT_DEF_PRIORITY_P3" }
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": True
}
},
"logsThreshold": {
"evaluationDelayMs": 60000,
"logsFilter": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"notificationPayloadFilter": ["obj.field"],
"rules": [
{
"condition": {
"conditionType": "LOGS_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"threshold": 100,
"timeWindow": { "logsTimeWindowSpecificValue": "LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED" }
},
"override": { "priority": "ALERT_DEF_PRIORITY_P3" }
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": True
}
},
"logsTimeRelativeThreshold": {
"evaluationDelayMs": 60000,
"ignoreInfinity": True,
"logsFilter": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"notificationPayloadFilter": ["obj.field"],
"rules": [
{
"condition": {
"comparedTo": "LOGS_TIME_RELATIVE_COMPARED_TO_YESTERDAY",
"conditionType": "LOGS_TIME_RELATIVE_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"threshold": 1
},
"override": { "priority": "ALERT_DEF_PRIORITY_P3" }
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": True
}
},
"logsUniqueCount": {
"logsFilter": { "simpleFilter": {
"labelFilters": {
"applicationName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
],
"severities": [],
"subsystemName": [
{
"operation": "LOG_FILTER_OPERATION_TYPE_INCLUDES",
"value": "my-app"
}
]
},
"luceneQuery": "<string>"
} },
"maxUniqueCountPerGroupByKey": "100",
"notificationPayloadFilter": ["obj.field"],
"rules": [{ "condition": {
"maxUniqueCount": "100",
"timeWindow": { "logsUniqueValueTimeWindowSpecificValue": "LOGS_UNIQUE_VALUE_TIME_WINDOW_VALUE_HOURS_12" }
} }],
"uniqueCountKeypath": "obj.field"
},
"metricAnomaly": {
"anomalyAlertSettings": { "percentageOfDeviation": 1 },
"evaluationDelayMs": 60000,
"metricFilter": { "promql": "avg_over_time(metric_name[5m]) > 10" },
"rules": [{ "condition": {
"conditionType": "METRIC_ANOMALY_CONDITION_TYPE_LESS_THAN_USUAL",
"forOverPct": 20,
"minNonNullValuesPct": 10,
"ofTheLast": {
"metricTimeWindowSpecificValue": "METRIC_TIME_WINDOW_VALUE_MINUTES_5",
"metricTimeWindowDynamicDuration": "1h30m"
},
"threshold": 10
} }]
},
"metricThreshold": {
"evaluationDelayMs": 60000,
"metricFilter": { "promql": "avg_over_time(metric_name[5m]) > 10" },
"missingValues": {
"replaceWithZero": True,
"minNonNullValuesPct": 80
},
"noDataPolicy": {
"autoRetireSeconds": 3600,
"state": "NO_DATA_POLICY_STATE_ALERTING"
},
"rules": [
{
"condition": {
"conditionType": "METRIC_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_EQUALS",
"forOverPct": 80,
"ofTheLast": {
"metricTimeWindowSpecificValue": "METRIC_TIME_WINDOW_VALUE_MINUTES_5",
"metricTimeWindowDynamicDuration": "1h30m"
},
"threshold": 100
},
"override": { "priority": "ALERT_DEF_PRIORITY_P3" }
}
],
"undetectedValuesManagement": {
"autoRetireTimeframe": "AUTO_RETIRE_TIMEFRAME_HOURS_24",
"triggerUndetectedValues": True
}
},
"name": "My Alert",
"notificationGroup": {
"destinations": [
{
"connectorId": "connector_id_example",
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED",
"presetId": "preset_id_example",
"resolvedRouteOverrides": { "configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
} },
"retriggeringPeriodMinutes": 600,
"triggeredRoutingOverrides": { "configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
} }
}
],
"groupByKeys": ["key1", "key2"],
"router": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"notifyOn": "NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED"
},
"webhooks": [
{
"integration": {
"integrationId": 123,
"recipients": { "emails": ["mail@gmail.com"] }
},
"minutes": 15,
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED"
}
]
},
"notificationGroupExcess": [
{
"destinations": [
{
"connectorId": "connector_id_example",
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED",
"presetId": "preset_id_example",
"resolvedRouteOverrides": { "configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
} },
"retriggeringPeriodMinutes": 600,
"triggeredRoutingOverrides": { "configOverrides": {
"connectorConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"messageConfigFields": [
{
"fieldName": "description",
"template": "template_example"
}
],
"payloadType": "slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default"
} }
}
],
"groupByKeys": ["key1", "key2"],
"router": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"notifyOn": "NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED"
},
"webhooks": [
{
"integration": {
"integrationId": 123,
"recipients": { "emails": ["mail@gmail.com"] }
},
"minutes": 15,
"notifyOn": "NOTIFY_ON_TRIGGERED_AND_RESOLVED"
}
]
}
],
"phantomMode": False,
"priority": "ALERT_DEF_PRIORITY_P4",
"sloThreshold": {
"errorBudget": { "rules": [
{
"condition": { "threshold": 1 },
"override": { "priority": "ALERT_DEF_PRIORITY_P3" }
}
] },
"burnRate": {
"dual": { "timeDuration": {
"duration": "24",
"unit": "DURATION_UNIT_HOURS"
} },
"rules": [
{
"condition": { "threshold": 1 },
"override": { "priority": "ALERT_DEF_PRIORITY_P3" }
}
],
"single": { "timeDuration": {
"duration": "24",
"unit": "DURATION_UNIT_HOURS"
} }
},
"sloDefinition": { "sloId": "123e4567-e89b-12d3-a456-426614174000" }
},
"tracingImmediate": {
"notificationPayloadFilter": ["obj.field"],
"tracingFilter": { "simpleFilter": {
"latencyThresholdMs": "1000",
"tracingLabelFilters": {
"applicationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
],
"operationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
],
"serviceName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
],
"spanFields": [
{
"filterType": {
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
},
"key": "span.field.key"
}
],
"subsystemName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
]
}
} }
},
"tracingThreshold": {
"notificationPayloadFilter": ["obj.field"],
"rules": [{ "condition": {
"conditionType": "TRACING_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED",
"spanAmount": 100,
"timeWindow": { "tracingTimeWindowValue": "TRACING_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED" }
} }],
"tracingFilter": { "simpleFilter": {
"latencyThresholdMs": "1000",
"tracingLabelFilters": {
"applicationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
],
"operationName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
],
"serviceName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
],
"spanFields": [
{
"filterType": {
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
},
"key": "span.field.key"
}
],
"subsystemName": [
{
"operation": "TRACING_FILTER_OPERATION_TYPE_STARTS_WITH",
"values": ["value1", "value2"]
}
]
}
} }
},
"type": "ALERT_DEF_TYPE_METRIC_THRESHOLD"
},
"accessPolicy": "<string>"
}
] }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
alertDefsToCreate: [
{
alertDefProperties: {
logsImmediate: {
logsFilter: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
notificationPayloadFilter: ['obj.field']
},
activeOn: {
dayOfWeek: ['DAY_OF_WEEK_MONDAY_OR_UNSPECIFIED', 'DAY_OF_WEEK_TUESDAY'],
endTime: {hours: 14, minutes: 30},
startTime: {hours: 14, minutes: 30}
},
analyticsImmediate: {
dataprimeQuery: {
query: 'source logs | filter severity == \'error\' | count_agg_key by applicationName'
},
evaluationDelayMs: 300000,
noDataPolicy: {autoRetireSeconds: 3600, state: 'NO_DATA_POLICY_STATE_ALERTING'},
timeframeMinutes: 60,
useRowsAsPermutations: false
},
analyticsThreshold: {
dataprimeQuery: {
query: 'source logs | filter severity == \'error\' | count_agg_key by applicationName'
},
evaluationDelayMs: 300000,
noDataPolicy: {autoRetireSeconds: 3600, state: 'NO_DATA_POLICY_STATE_ALERTING'},
operator: 'ANALYTICS_THRESHOLD_OPERATOR_MORE_THAN_OR_UNSPECIFIED',
rules: [{condition: {threshold: 100}, override: {priority: 'ALERT_DEF_PRIORITY_P3'}}],
targetColumn: 'error_count',
timeframeMinutes: 60,
useRowsAsPermutations: true
},
dataSources: [{dataSet: '<string>', dataSpace: '<string>'}],
deleted: false,
description: 'Alert description',
enabled: true,
entityLabels: {},
flow: {
enforceSuppression: true,
stages: [
{
flowStagesGroups: {
groups: [
{
alertDefs: [{id: '123e4567-e89b-12d3-a456-426614174000', not: true}],
alertsOp: 'ALERTS_OP_OR',
nextOp: 'NEXT_OP_OR'
}
]
},
timeframeMs: '<string>',
timeframeType: 'TIMEFRAME_TYPE_UP_TO'
}
]
},
groupByKeys: ['key1', 'key2'],
incidentsSettings: {minutes: 30, notifyOn: 'NOTIFY_ON_TRIGGERED_AND_RESOLVED'},
logsAnomaly: {
anomalyAlertSettings: {percentageOfDeviation: 1},
evaluationDelayMs: 60000,
logsFilter: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
notificationPayloadFilter: ['obj.field'],
rules: [
{
condition: {
conditionType: 'LOGS_ANOMALY_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
minimumThreshold: 10,
timeWindow: {logsTimeWindowSpecificValue: 'LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED'}
}
}
]
},
logsNewValue: {
logsFilter: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
notificationPayloadFilter: ['obj.field'],
rules: [
{
condition: {
keypathToTrack: 'metadata.field',
timeWindow: {
logsNewValueTimeWindowSpecificValue: 'LOGS_NEW_VALUE_TIME_WINDOW_VALUE_HOURS_12_OR_UNSPECIFIED'
}
}
}
]
},
logsRatioThreshold: {
denominator: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
denominatorAlias: 'denominator_alias',
evaluationDelayMs: 60000,
groupByFor: 'LOGS_RATIO_GROUP_BY_FOR_NUMERATOR_ONLY',
ignoreInfinity: true,
notificationPayloadFilter: ['obj.field'],
numerator: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
numeratorAlias: 'numerator_alias',
rules: [
{
condition: {
conditionType: 'LOGS_RATIO_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
threshold: 10,
timeWindow: 10
},
override: {priority: 'ALERT_DEF_PRIORITY_P3'}
}
],
undetectedValuesManagement: {
autoRetireTimeframe: 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
triggerUndetectedValues: true
}
},
logsThreshold: {
evaluationDelayMs: 60000,
logsFilter: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
noDataPolicy: {autoRetireSeconds: 3600, state: 'NO_DATA_POLICY_STATE_ALERTING'},
notificationPayloadFilter: ['obj.field'],
rules: [
{
condition: {
conditionType: 'LOGS_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
threshold: 100,
timeWindow: {logsTimeWindowSpecificValue: 'LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED'}
},
override: {priority: 'ALERT_DEF_PRIORITY_P3'}
}
],
undetectedValuesManagement: {
autoRetireTimeframe: 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
triggerUndetectedValues: true
}
},
logsTimeRelativeThreshold: {
evaluationDelayMs: 60000,
ignoreInfinity: true,
logsFilter: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
notificationPayloadFilter: ['obj.field'],
rules: [
{
condition: {
comparedTo: 'LOGS_TIME_RELATIVE_COMPARED_TO_YESTERDAY',
conditionType: 'LOGS_TIME_RELATIVE_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
threshold: 1
},
override: {priority: 'ALERT_DEF_PRIORITY_P3'}
}
],
undetectedValuesManagement: {
autoRetireTimeframe: 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
triggerUndetectedValues: true
}
},
logsUniqueCount: {
logsFilter: {
simpleFilter: {
labelFilters: {
applicationName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}],
severities: [],
subsystemName: [{operation: 'LOG_FILTER_OPERATION_TYPE_INCLUDES', value: 'my-app'}]
},
luceneQuery: '<string>'
}
},
maxUniqueCountPerGroupByKey: '100',
notificationPayloadFilter: ['obj.field'],
rules: [
{
condition: {
maxUniqueCount: '100',
timeWindow: {
logsUniqueValueTimeWindowSpecificValue: 'LOGS_UNIQUE_VALUE_TIME_WINDOW_VALUE_HOURS_12'
}
}
}
],
uniqueCountKeypath: 'obj.field'
},
metricAnomaly: {
anomalyAlertSettings: {percentageOfDeviation: 1},
evaluationDelayMs: 60000,
metricFilter: {promql: 'avg_over_time(metric_name[5m]) > 10'},
rules: [
{
condition: {
conditionType: 'METRIC_ANOMALY_CONDITION_TYPE_LESS_THAN_USUAL',
forOverPct: 20,
minNonNullValuesPct: 10,
ofTheLast: {
metricTimeWindowSpecificValue: 'METRIC_TIME_WINDOW_VALUE_MINUTES_5',
metricTimeWindowDynamicDuration: '1h30m'
},
threshold: 10
}
}
]
},
metricThreshold: {
evaluationDelayMs: 60000,
metricFilter: {promql: 'avg_over_time(metric_name[5m]) > 10'},
missingValues: {replaceWithZero: true, minNonNullValuesPct: 80},
noDataPolicy: {autoRetireSeconds: 3600, state: 'NO_DATA_POLICY_STATE_ALERTING'},
rules: [
{
condition: {
conditionType: 'METRIC_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_EQUALS',
forOverPct: 80,
ofTheLast: {
metricTimeWindowSpecificValue: 'METRIC_TIME_WINDOW_VALUE_MINUTES_5',
metricTimeWindowDynamicDuration: '1h30m'
},
threshold: 100
},
override: {priority: 'ALERT_DEF_PRIORITY_P3'}
}
],
undetectedValuesManagement: {
autoRetireTimeframe: 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
triggerUndetectedValues: true
}
},
name: 'My Alert',
notificationGroup: {
destinations: [
{
connectorId: 'connector_id_example',
notifyOn: 'NOTIFY_ON_TRIGGERED_AND_RESOLVED',
presetId: 'preset_id_example',
resolvedRouteOverrides: {
configOverrides: {
connectorConfigFields: [{fieldName: 'description', template: 'template_example'}],
messageConfigFields: [{fieldName: 'description', template: 'template_example'}],
payloadType: 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
}
},
retriggeringPeriodMinutes: 600,
triggeredRoutingOverrides: {
configOverrides: {
connectorConfigFields: [{fieldName: 'description', template: 'template_example'}],
messageConfigFields: [{fieldName: 'description', template: 'template_example'}],
payloadType: 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
}
}
}
],
groupByKeys: ['key1', 'key2'],
router: {
id: '123e4567-e89b-12d3-a456-426614174000',
notifyOn: 'NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED'
},
webhooks: [
{
integration: {integrationId: 123, recipients: {emails: ['mail@gmail.com']}},
minutes: 15,
notifyOn: 'NOTIFY_ON_TRIGGERED_AND_RESOLVED'
}
]
},
notificationGroupExcess: [
{
destinations: [
{
connectorId: 'connector_id_example',
notifyOn: 'NOTIFY_ON_TRIGGERED_AND_RESOLVED',
presetId: 'preset_id_example',
resolvedRouteOverrides: {
configOverrides: {
connectorConfigFields: [{fieldName: 'description', template: 'template_example'}],
messageConfigFields: [{fieldName: 'description', template: 'template_example'}],
payloadType: 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
}
},
retriggeringPeriodMinutes: 600,
triggeredRoutingOverrides: {
configOverrides: {
connectorConfigFields: [{fieldName: 'description', template: 'template_example'}],
messageConfigFields: [{fieldName: 'description', template: 'template_example'}],
payloadType: 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
}
}
}
],
groupByKeys: ['key1', 'key2'],
router: {
id: '123e4567-e89b-12d3-a456-426614174000',
notifyOn: 'NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED'
},
webhooks: [
{
integration: {integrationId: 123, recipients: {emails: ['mail@gmail.com']}},
minutes: 15,
notifyOn: 'NOTIFY_ON_TRIGGERED_AND_RESOLVED'
}
]
}
],
phantomMode: false,
priority: 'ALERT_DEF_PRIORITY_P4',
sloThreshold: {
errorBudget: {
rules: [{condition: {threshold: 1}, override: {priority: 'ALERT_DEF_PRIORITY_P3'}}]
},
burnRate: {
dual: {timeDuration: {duration: '24', unit: 'DURATION_UNIT_HOURS'}},
rules: [{condition: {threshold: 1}, override: {priority: 'ALERT_DEF_PRIORITY_P3'}}],
single: {timeDuration: {duration: '24', unit: 'DURATION_UNIT_HOURS'}}
},
sloDefinition: {sloId: '123e4567-e89b-12d3-a456-426614174000'}
},
tracingImmediate: {
notificationPayloadFilter: ['obj.field'],
tracingFilter: {
simpleFilter: {
latencyThresholdMs: '1000',
tracingLabelFilters: {
applicationName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
],
operationName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
],
serviceName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
],
spanFields: [
{
filterType: {
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
},
key: 'span.field.key'
}
],
subsystemName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
]
}
}
}
},
tracingThreshold: {
notificationPayloadFilter: ['obj.field'],
rules: [
{
condition: {
conditionType: 'TRACING_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
spanAmount: 100,
timeWindow: {tracingTimeWindowValue: 'TRACING_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED'}
}
}
],
tracingFilter: {
simpleFilter: {
latencyThresholdMs: '1000',
tracingLabelFilters: {
applicationName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
],
operationName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
],
serviceName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
],
spanFields: [
{
filterType: {
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
},
key: 'span.field.key'
}
],
subsystemName: [
{
operation: 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
values: ['value1', 'value2']
}
]
}
}
}
},
type: 'ALERT_DEF_TYPE_METRIC_THRESHOLD'
},
accessPolicy: '<string>'
}
]
})
};
fetch('https://api.coralogix.com/mgmt/openapi/5/alerts/alerts/v3/all/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.coralogix.com/mgmt/openapi/5/alerts/alerts/v3/all/create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'alertDefsToCreate' => [
[
'alertDefProperties' => [
'logsImmediate' => [
'logsFilter' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'notificationPayloadFilter' => [
'obj.field'
]
],
'activeOn' => [
'dayOfWeek' => [
'DAY_OF_WEEK_MONDAY_OR_UNSPECIFIED',
'DAY_OF_WEEK_TUESDAY'
],
'endTime' => [
'hours' => 14,
'minutes' => 30
],
'startTime' => [
'hours' => 14,
'minutes' => 30
]
],
'analyticsImmediate' => [
'dataprimeQuery' => [
'query' => 'source logs | filter severity == \'error\' | count_agg_key by applicationName'
],
'evaluationDelayMs' => 300000,
'noDataPolicy' => [
'autoRetireSeconds' => 3600,
'state' => 'NO_DATA_POLICY_STATE_ALERTING'
],
'timeframeMinutes' => 60,
'useRowsAsPermutations' => false
],
'analyticsThreshold' => [
'dataprimeQuery' => [
'query' => 'source logs | filter severity == \'error\' | count_agg_key by applicationName'
],
'evaluationDelayMs' => 300000,
'noDataPolicy' => [
'autoRetireSeconds' => 3600,
'state' => 'NO_DATA_POLICY_STATE_ALERTING'
],
'operator' => 'ANALYTICS_THRESHOLD_OPERATOR_MORE_THAN_OR_UNSPECIFIED',
'rules' => [
[
'condition' => [
'threshold' => 100
],
'override' => [
'priority' => 'ALERT_DEF_PRIORITY_P3'
]
]
],
'targetColumn' => 'error_count',
'timeframeMinutes' => 60,
'useRowsAsPermutations' => true
],
'dataSources' => [
[
'dataSet' => '<string>',
'dataSpace' => '<string>'
]
],
'deleted' => false,
'description' => 'Alert description',
'enabled' => true,
'entityLabels' => [
],
'flow' => [
'enforceSuppression' => true,
'stages' => [
[
'flowStagesGroups' => [
'groups' => [
[
'alertDefs' => [
[
'id' => '123e4567-e89b-12d3-a456-426614174000',
'not' => true
]
],
'alertsOp' => 'ALERTS_OP_OR',
'nextOp' => 'NEXT_OP_OR'
]
]
],
'timeframeMs' => '<string>',
'timeframeType' => 'TIMEFRAME_TYPE_UP_TO'
]
]
],
'groupByKeys' => [
'key1',
'key2'
],
'incidentsSettings' => [
'minutes' => 30,
'notifyOn' => 'NOTIFY_ON_TRIGGERED_AND_RESOLVED'
],
'logsAnomaly' => [
'anomalyAlertSettings' => [
'percentageOfDeviation' => 1
],
'evaluationDelayMs' => 60000,
'logsFilter' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'notificationPayloadFilter' => [
'obj.field'
],
'rules' => [
[
'condition' => [
'conditionType' => 'LOGS_ANOMALY_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
'minimumThreshold' => 10,
'timeWindow' => [
'logsTimeWindowSpecificValue' => 'LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED'
]
]
]
]
],
'logsNewValue' => [
'logsFilter' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'notificationPayloadFilter' => [
'obj.field'
],
'rules' => [
[
'condition' => [
'keypathToTrack' => 'metadata.field',
'timeWindow' => [
'logsNewValueTimeWindowSpecificValue' => 'LOGS_NEW_VALUE_TIME_WINDOW_VALUE_HOURS_12_OR_UNSPECIFIED'
]
]
]
]
],
'logsRatioThreshold' => [
'denominator' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'denominatorAlias' => 'denominator_alias',
'evaluationDelayMs' => 60000,
'groupByFor' => 'LOGS_RATIO_GROUP_BY_FOR_NUMERATOR_ONLY',
'ignoreInfinity' => true,
'notificationPayloadFilter' => [
'obj.field'
],
'numerator' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'numeratorAlias' => 'numerator_alias',
'rules' => [
[
'condition' => [
'conditionType' => 'LOGS_RATIO_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
'threshold' => 10,
'timeWindow' => 10
],
'override' => [
'priority' => 'ALERT_DEF_PRIORITY_P3'
]
]
],
'undetectedValuesManagement' => [
'autoRetireTimeframe' => 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
'triggerUndetectedValues' => true
]
],
'logsThreshold' => [
'evaluationDelayMs' => 60000,
'logsFilter' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'noDataPolicy' => [
'autoRetireSeconds' => 3600,
'state' => 'NO_DATA_POLICY_STATE_ALERTING'
],
'notificationPayloadFilter' => [
'obj.field'
],
'rules' => [
[
'condition' => [
'conditionType' => 'LOGS_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
'threshold' => 100,
'timeWindow' => [
'logsTimeWindowSpecificValue' => 'LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED'
]
],
'override' => [
'priority' => 'ALERT_DEF_PRIORITY_P3'
]
]
],
'undetectedValuesManagement' => [
'autoRetireTimeframe' => 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
'triggerUndetectedValues' => true
]
],
'logsTimeRelativeThreshold' => [
'evaluationDelayMs' => 60000,
'ignoreInfinity' => true,
'logsFilter' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'notificationPayloadFilter' => [
'obj.field'
],
'rules' => [
[
'condition' => [
'comparedTo' => 'LOGS_TIME_RELATIVE_COMPARED_TO_YESTERDAY',
'conditionType' => 'LOGS_TIME_RELATIVE_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
'threshold' => 1
],
'override' => [
'priority' => 'ALERT_DEF_PRIORITY_P3'
]
]
],
'undetectedValuesManagement' => [
'autoRetireTimeframe' => 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
'triggerUndetectedValues' => true
]
],
'logsUniqueCount' => [
'logsFilter' => [
'simpleFilter' => [
'labelFilters' => [
'applicationName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
],
'severities' => [
],
'subsystemName' => [
[
'operation' => 'LOG_FILTER_OPERATION_TYPE_INCLUDES',
'value' => 'my-app'
]
]
],
'luceneQuery' => '<string>'
]
],
'maxUniqueCountPerGroupByKey' => '100',
'notificationPayloadFilter' => [
'obj.field'
],
'rules' => [
[
'condition' => [
'maxUniqueCount' => '100',
'timeWindow' => [
'logsUniqueValueTimeWindowSpecificValue' => 'LOGS_UNIQUE_VALUE_TIME_WINDOW_VALUE_HOURS_12'
]
]
]
],
'uniqueCountKeypath' => 'obj.field'
],
'metricAnomaly' => [
'anomalyAlertSettings' => [
'percentageOfDeviation' => 1
],
'evaluationDelayMs' => 60000,
'metricFilter' => [
'promql' => 'avg_over_time(metric_name[5m]) > 10'
],
'rules' => [
[
'condition' => [
'conditionType' => 'METRIC_ANOMALY_CONDITION_TYPE_LESS_THAN_USUAL',
'forOverPct' => 20,
'minNonNullValuesPct' => 10,
'ofTheLast' => [
'metricTimeWindowSpecificValue' => 'METRIC_TIME_WINDOW_VALUE_MINUTES_5',
'metricTimeWindowDynamicDuration' => '1h30m'
],
'threshold' => 10
]
]
]
],
'metricThreshold' => [
'evaluationDelayMs' => 60000,
'metricFilter' => [
'promql' => 'avg_over_time(metric_name[5m]) > 10'
],
'missingValues' => [
'replaceWithZero' => true,
'minNonNullValuesPct' => 80
],
'noDataPolicy' => [
'autoRetireSeconds' => 3600,
'state' => 'NO_DATA_POLICY_STATE_ALERTING'
],
'rules' => [
[
'condition' => [
'conditionType' => 'METRIC_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_EQUALS',
'forOverPct' => 80,
'ofTheLast' => [
'metricTimeWindowSpecificValue' => 'METRIC_TIME_WINDOW_VALUE_MINUTES_5',
'metricTimeWindowDynamicDuration' => '1h30m'
],
'threshold' => 100
],
'override' => [
'priority' => 'ALERT_DEF_PRIORITY_P3'
]
]
],
'undetectedValuesManagement' => [
'autoRetireTimeframe' => 'AUTO_RETIRE_TIMEFRAME_HOURS_24',
'triggerUndetectedValues' => true
]
],
'name' => 'My Alert',
'notificationGroup' => [
'destinations' => [
[
'connectorId' => 'connector_id_example',
'notifyOn' => 'NOTIFY_ON_TRIGGERED_AND_RESOLVED',
'presetId' => 'preset_id_example',
'resolvedRouteOverrides' => [
'configOverrides' => [
'connectorConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'messageConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'payloadType' => 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
]
],
'retriggeringPeriodMinutes' => 600,
'triggeredRoutingOverrides' => [
'configOverrides' => [
'connectorConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'messageConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'payloadType' => 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
]
]
]
],
'groupByKeys' => [
'key1',
'key2'
],
'router' => [
'id' => '123e4567-e89b-12d3-a456-426614174000',
'notifyOn' => 'NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED'
],
'webhooks' => [
[
'integration' => [
'integrationId' => 123,
'recipients' => [
'emails' => [
'mail@gmail.com'
]
]
],
'minutes' => 15,
'notifyOn' => 'NOTIFY_ON_TRIGGERED_AND_RESOLVED'
]
]
],
'notificationGroupExcess' => [
[
'destinations' => [
[
'connectorId' => 'connector_id_example',
'notifyOn' => 'NOTIFY_ON_TRIGGERED_AND_RESOLVED',
'presetId' => 'preset_id_example',
'resolvedRouteOverrides' => [
'configOverrides' => [
'connectorConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'messageConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'payloadType' => 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
]
],
'retriggeringPeriodMinutes' => 600,
'triggeredRoutingOverrides' => [
'configOverrides' => [
'connectorConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'messageConfigFields' => [
[
'fieldName' => 'description',
'template' => 'template_example'
]
],
'payloadType' => 'slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default'
]
]
]
],
'groupByKeys' => [
'key1',
'key2'
],
'router' => [
'id' => '123e4567-e89b-12d3-a456-426614174000',
'notifyOn' => 'NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED'
],
'webhooks' => [
[
'integration' => [
'integrationId' => 123,
'recipients' => [
'emails' => [
'mail@gmail.com'
]
]
],
'minutes' => 15,
'notifyOn' => 'NOTIFY_ON_TRIGGERED_AND_RESOLVED'
]
]
]
],
'phantomMode' => false,
'priority' => 'ALERT_DEF_PRIORITY_P4',
'sloThreshold' => [
'errorBudget' => [
'rules' => [
[
'condition' => [
'threshold' => 1
],
'override' => [
'priority' => 'ALERT_DEF_PRIORITY_P3'
]
]
]
],
'burnRate' => [
'dual' => [
'timeDuration' => [
'duration' => '24',
'unit' => 'DURATION_UNIT_HOURS'
]
],
'rules' => [
[
'condition' => [
'threshold' => 1
],
'override' => [
'priority' => 'ALERT_DEF_PRIORITY_P3'
]
]
],
'single' => [
'timeDuration' => [
'duration' => '24',
'unit' => 'DURATION_UNIT_HOURS'
]
]
],
'sloDefinition' => [
'sloId' => '123e4567-e89b-12d3-a456-426614174000'
]
],
'tracingImmediate' => [
'notificationPayloadFilter' => [
'obj.field'
],
'tracingFilter' => [
'simpleFilter' => [
'latencyThresholdMs' => '1000',
'tracingLabelFilters' => [
'applicationName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
],
'operationName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
],
'serviceName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
],
'spanFields' => [
[
'filterType' => [
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
],
'key' => 'span.field.key'
]
],
'subsystemName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
]
]
]
]
],
'tracingThreshold' => [
'notificationPayloadFilter' => [
'obj.field'
],
'rules' => [
[
'condition' => [
'conditionType' => 'TRACING_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED',
'spanAmount' => 100,
'timeWindow' => [
'tracingTimeWindowValue' => 'TRACING_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED'
]
]
]
],
'tracingFilter' => [
'simpleFilter' => [
'latencyThresholdMs' => '1000',
'tracingLabelFilters' => [
'applicationName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
],
'operationName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
],
'serviceName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
],
'spanFields' => [
[
'filterType' => [
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
],
'key' => 'span.field.key'
]
],
'subsystemName' => [
[
'operation' => 'TRACING_FILTER_OPERATION_TYPE_STARTS_WITH',
'values' => [
'value1',
'value2'
]
]
]
]
]
]
],
'type' => 'ALERT_DEF_TYPE_METRIC_THRESHOLD'
],
'accessPolicy' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.coralogix.com/mgmt/openapi/5/alerts/alerts/v3/all/create"
payload := strings.NewReader("{\n \"alertDefsToCreate\": [\n {\n \"alertDefProperties\": {\n \"logsImmediate\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ]\n },\n \"activeOn\": {\n \"dayOfWeek\": [\n \"DAY_OF_WEEK_MONDAY_OR_UNSPECIFIED\",\n \"DAY_OF_WEEK_TUESDAY\"\n ],\n \"endTime\": {\n \"hours\": 14,\n \"minutes\": 30\n },\n \"startTime\": {\n \"hours\": 14,\n \"minutes\": 30\n }\n },\n \"analyticsImmediate\": {\n \"dataprimeQuery\": {\n \"query\": \"source logs | filter severity == 'error' | count_agg_key by applicationName\"\n },\n \"evaluationDelayMs\": 300000,\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"timeframeMinutes\": 60,\n \"useRowsAsPermutations\": false\n },\n \"analyticsThreshold\": {\n \"dataprimeQuery\": {\n \"query\": \"source logs | filter severity == 'error' | count_agg_key by applicationName\"\n },\n \"evaluationDelayMs\": 300000,\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"operator\": \"ANALYTICS_THRESHOLD_OPERATOR_MORE_THAN_OR_UNSPECIFIED\",\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 100\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"targetColumn\": \"error_count\",\n \"timeframeMinutes\": 60,\n \"useRowsAsPermutations\": true\n },\n \"dataSources\": [\n {\n \"dataSet\": \"<string>\",\n \"dataSpace\": \"<string>\"\n }\n ],\n \"deleted\": false,\n \"description\": \"Alert description\",\n \"enabled\": true,\n \"entityLabels\": {},\n \"flow\": {\n \"enforceSuppression\": true,\n \"stages\": [\n {\n \"flowStagesGroups\": {\n \"groups\": [\n {\n \"alertDefs\": [\n {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"not\": true\n }\n ],\n \"alertsOp\": \"ALERTS_OP_OR\",\n \"nextOp\": \"NEXT_OP_OR\"\n }\n ]\n },\n \"timeframeMs\": \"<string>\",\n \"timeframeType\": \"TIMEFRAME_TYPE_UP_TO\"\n }\n ]\n },\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"incidentsSettings\": {\n \"minutes\": 30,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n },\n \"logsAnomaly\": {\n \"anomalyAlertSettings\": {\n \"percentageOfDeviation\": 1\n },\n \"evaluationDelayMs\": 60000,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_ANOMALY_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"minimumThreshold\": 10,\n \"timeWindow\": {\n \"logsTimeWindowSpecificValue\": \"LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n }\n }\n ]\n },\n \"logsNewValue\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"keypathToTrack\": \"metadata.field\",\n \"timeWindow\": {\n \"logsNewValueTimeWindowSpecificValue\": \"LOGS_NEW_VALUE_TIME_WINDOW_VALUE_HOURS_12_OR_UNSPECIFIED\"\n }\n }\n }\n ]\n },\n \"logsRatioThreshold\": {\n \"denominator\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"denominatorAlias\": \"denominator_alias\",\n \"evaluationDelayMs\": 60000,\n \"groupByFor\": \"LOGS_RATIO_GROUP_BY_FOR_NUMERATOR_ONLY\",\n \"ignoreInfinity\": true,\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"numerator\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"numeratorAlias\": \"numerator_alias\",\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_RATIO_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 10,\n \"timeWindow\": 10\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 100,\n \"timeWindow\": {\n \"logsTimeWindowSpecificValue\": \"LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsTimeRelativeThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"ignoreInfinity\": true,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"comparedTo\": \"LOGS_TIME_RELATIVE_COMPARED_TO_YESTERDAY\",\n \"conditionType\": \"LOGS_TIME_RELATIVE_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsUniqueCount\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"maxUniqueCountPerGroupByKey\": \"100\",\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"maxUniqueCount\": \"100\",\n \"timeWindow\": {\n \"logsUniqueValueTimeWindowSpecificValue\": \"LOGS_UNIQUE_VALUE_TIME_WINDOW_VALUE_HOURS_12\"\n }\n }\n }\n ],\n \"uniqueCountKeypath\": \"obj.field\"\n },\n \"metricAnomaly\": {\n \"anomalyAlertSettings\": {\n \"percentageOfDeviation\": 1\n },\n \"evaluationDelayMs\": 60000,\n \"metricFilter\": {\n \"promql\": \"avg_over_time(metric_name[5m]) > 10\"\n },\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"METRIC_ANOMALY_CONDITION_TYPE_LESS_THAN_USUAL\",\n \"forOverPct\": 20,\n \"minNonNullValuesPct\": 10,\n \"ofTheLast\": {\n \"metricTimeWindowSpecificValue\": \"METRIC_TIME_WINDOW_VALUE_MINUTES_5\",\n \"metricTimeWindowDynamicDuration\": \"1h30m\"\n },\n \"threshold\": 10\n }\n }\n ]\n },\n \"metricThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"metricFilter\": {\n \"promql\": \"avg_over_time(metric_name[5m]) > 10\"\n },\n \"missingValues\": {\n \"replaceWithZero\": true,\n \"minNonNullValuesPct\": 80\n },\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"METRIC_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_EQUALS\",\n \"forOverPct\": 80,\n \"ofTheLast\": {\n \"metricTimeWindowSpecificValue\": \"METRIC_TIME_WINDOW_VALUE_MINUTES_5\",\n \"metricTimeWindowDynamicDuration\": \"1h30m\"\n },\n \"threshold\": 100\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"name\": \"My Alert\",\n \"notificationGroup\": {\n \"destinations\": [\n {\n \"connectorId\": \"connector_id_example\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\",\n \"presetId\": \"preset_id_example\",\n \"resolvedRouteOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n },\n \"retriggeringPeriodMinutes\": 600,\n \"triggeredRoutingOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n }\n }\n ],\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"router\": {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED\"\n },\n \"webhooks\": [\n {\n \"integration\": {\n \"integrationId\": 123,\n \"recipients\": {\n \"emails\": [\n \"mail@gmail.com\"\n ]\n }\n },\n \"minutes\": 15,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n }\n ]\n },\n \"notificationGroupExcess\": [\n {\n \"destinations\": [\n {\n \"connectorId\": \"connector_id_example\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\",\n \"presetId\": \"preset_id_example\",\n \"resolvedRouteOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n },\n \"retriggeringPeriodMinutes\": 600,\n \"triggeredRoutingOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n }\n }\n ],\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"router\": {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED\"\n },\n \"webhooks\": [\n {\n \"integration\": {\n \"integrationId\": 123,\n \"recipients\": {\n \"emails\": [\n \"mail@gmail.com\"\n ]\n }\n },\n \"minutes\": 15,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n }\n ]\n }\n ],\n \"phantomMode\": false,\n \"priority\": \"ALERT_DEF_PRIORITY_P4\",\n \"sloThreshold\": {\n \"errorBudget\": {\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ]\n },\n \"burnRate\": {\n \"dual\": {\n \"timeDuration\": {\n \"duration\": \"24\",\n \"unit\": \"DURATION_UNIT_HOURS\"\n }\n },\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"single\": {\n \"timeDuration\": {\n \"duration\": \"24\",\n \"unit\": \"DURATION_UNIT_HOURS\"\n }\n }\n },\n \"sloDefinition\": {\n \"sloId\": \"123e4567-e89b-12d3-a456-426614174000\"\n }\n },\n \"tracingImmediate\": {\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"tracingFilter\": {\n \"simpleFilter\": {\n \"latencyThresholdMs\": \"1000\",\n \"tracingLabelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"operationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"serviceName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"spanFields\": [\n {\n \"filterType\": {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n },\n \"key\": \"span.field.key\"\n }\n ],\n \"subsystemName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ]\n }\n }\n }\n },\n \"tracingThreshold\": {\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"TRACING_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"spanAmount\": 100,\n \"timeWindow\": {\n \"tracingTimeWindowValue\": \"TRACING_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n }\n }\n ],\n \"tracingFilter\": {\n \"simpleFilter\": {\n \"latencyThresholdMs\": \"1000\",\n \"tracingLabelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"operationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"serviceName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"spanFields\": [\n {\n \"filterType\": {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n },\n \"key\": \"span.field.key\"\n }\n ],\n \"subsystemName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ]\n }\n }\n }\n },\n \"type\": \"ALERT_DEF_TYPE_METRIC_THRESHOLD\"\n },\n \"accessPolicy\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.coralogix.com/mgmt/openapi/5/alerts/alerts/v3/all/create")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"alertDefsToCreate\": [\n {\n \"alertDefProperties\": {\n \"logsImmediate\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ]\n },\n \"activeOn\": {\n \"dayOfWeek\": [\n \"DAY_OF_WEEK_MONDAY_OR_UNSPECIFIED\",\n \"DAY_OF_WEEK_TUESDAY\"\n ],\n \"endTime\": {\n \"hours\": 14,\n \"minutes\": 30\n },\n \"startTime\": {\n \"hours\": 14,\n \"minutes\": 30\n }\n },\n \"analyticsImmediate\": {\n \"dataprimeQuery\": {\n \"query\": \"source logs | filter severity == 'error' | count_agg_key by applicationName\"\n },\n \"evaluationDelayMs\": 300000,\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"timeframeMinutes\": 60,\n \"useRowsAsPermutations\": false\n },\n \"analyticsThreshold\": {\n \"dataprimeQuery\": {\n \"query\": \"source logs | filter severity == 'error' | count_agg_key by applicationName\"\n },\n \"evaluationDelayMs\": 300000,\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"operator\": \"ANALYTICS_THRESHOLD_OPERATOR_MORE_THAN_OR_UNSPECIFIED\",\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 100\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"targetColumn\": \"error_count\",\n \"timeframeMinutes\": 60,\n \"useRowsAsPermutations\": true\n },\n \"dataSources\": [\n {\n \"dataSet\": \"<string>\",\n \"dataSpace\": \"<string>\"\n }\n ],\n \"deleted\": false,\n \"description\": \"Alert description\",\n \"enabled\": true,\n \"entityLabels\": {},\n \"flow\": {\n \"enforceSuppression\": true,\n \"stages\": [\n {\n \"flowStagesGroups\": {\n \"groups\": [\n {\n \"alertDefs\": [\n {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"not\": true\n }\n ],\n \"alertsOp\": \"ALERTS_OP_OR\",\n \"nextOp\": \"NEXT_OP_OR\"\n }\n ]\n },\n \"timeframeMs\": \"<string>\",\n \"timeframeType\": \"TIMEFRAME_TYPE_UP_TO\"\n }\n ]\n },\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"incidentsSettings\": {\n \"minutes\": 30,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n },\n \"logsAnomaly\": {\n \"anomalyAlertSettings\": {\n \"percentageOfDeviation\": 1\n },\n \"evaluationDelayMs\": 60000,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_ANOMALY_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"minimumThreshold\": 10,\n \"timeWindow\": {\n \"logsTimeWindowSpecificValue\": \"LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n }\n }\n ]\n },\n \"logsNewValue\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"keypathToTrack\": \"metadata.field\",\n \"timeWindow\": {\n \"logsNewValueTimeWindowSpecificValue\": \"LOGS_NEW_VALUE_TIME_WINDOW_VALUE_HOURS_12_OR_UNSPECIFIED\"\n }\n }\n }\n ]\n },\n \"logsRatioThreshold\": {\n \"denominator\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"denominatorAlias\": \"denominator_alias\",\n \"evaluationDelayMs\": 60000,\n \"groupByFor\": \"LOGS_RATIO_GROUP_BY_FOR_NUMERATOR_ONLY\",\n \"ignoreInfinity\": true,\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"numerator\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"numeratorAlias\": \"numerator_alias\",\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_RATIO_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 10,\n \"timeWindow\": 10\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 100,\n \"timeWindow\": {\n \"logsTimeWindowSpecificValue\": \"LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsTimeRelativeThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"ignoreInfinity\": true,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"comparedTo\": \"LOGS_TIME_RELATIVE_COMPARED_TO_YESTERDAY\",\n \"conditionType\": \"LOGS_TIME_RELATIVE_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsUniqueCount\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"maxUniqueCountPerGroupByKey\": \"100\",\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"maxUniqueCount\": \"100\",\n \"timeWindow\": {\n \"logsUniqueValueTimeWindowSpecificValue\": \"LOGS_UNIQUE_VALUE_TIME_WINDOW_VALUE_HOURS_12\"\n }\n }\n }\n ],\n \"uniqueCountKeypath\": \"obj.field\"\n },\n \"metricAnomaly\": {\n \"anomalyAlertSettings\": {\n \"percentageOfDeviation\": 1\n },\n \"evaluationDelayMs\": 60000,\n \"metricFilter\": {\n \"promql\": \"avg_over_time(metric_name[5m]) > 10\"\n },\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"METRIC_ANOMALY_CONDITION_TYPE_LESS_THAN_USUAL\",\n \"forOverPct\": 20,\n \"minNonNullValuesPct\": 10,\n \"ofTheLast\": {\n \"metricTimeWindowSpecificValue\": \"METRIC_TIME_WINDOW_VALUE_MINUTES_5\",\n \"metricTimeWindowDynamicDuration\": \"1h30m\"\n },\n \"threshold\": 10\n }\n }\n ]\n },\n \"metricThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"metricFilter\": {\n \"promql\": \"avg_over_time(metric_name[5m]) > 10\"\n },\n \"missingValues\": {\n \"replaceWithZero\": true,\n \"minNonNullValuesPct\": 80\n },\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"METRIC_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_EQUALS\",\n \"forOverPct\": 80,\n \"ofTheLast\": {\n \"metricTimeWindowSpecificValue\": \"METRIC_TIME_WINDOW_VALUE_MINUTES_5\",\n \"metricTimeWindowDynamicDuration\": \"1h30m\"\n },\n \"threshold\": 100\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"name\": \"My Alert\",\n \"notificationGroup\": {\n \"destinations\": [\n {\n \"connectorId\": \"connector_id_example\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\",\n \"presetId\": \"preset_id_example\",\n \"resolvedRouteOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n },\n \"retriggeringPeriodMinutes\": 600,\n \"triggeredRoutingOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n }\n }\n ],\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"router\": {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED\"\n },\n \"webhooks\": [\n {\n \"integration\": {\n \"integrationId\": 123,\n \"recipients\": {\n \"emails\": [\n \"mail@gmail.com\"\n ]\n }\n },\n \"minutes\": 15,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n }\n ]\n },\n \"notificationGroupExcess\": [\n {\n \"destinations\": [\n {\n \"connectorId\": \"connector_id_example\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\",\n \"presetId\": \"preset_id_example\",\n \"resolvedRouteOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n },\n \"retriggeringPeriodMinutes\": 600,\n \"triggeredRoutingOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n }\n }\n ],\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"router\": {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED\"\n },\n \"webhooks\": [\n {\n \"integration\": {\n \"integrationId\": 123,\n \"recipients\": {\n \"emails\": [\n \"mail@gmail.com\"\n ]\n }\n },\n \"minutes\": 15,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n }\n ]\n }\n ],\n \"phantomMode\": false,\n \"priority\": \"ALERT_DEF_PRIORITY_P4\",\n \"sloThreshold\": {\n \"errorBudget\": {\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ]\n },\n \"burnRate\": {\n \"dual\": {\n \"timeDuration\": {\n \"duration\": \"24\",\n \"unit\": \"DURATION_UNIT_HOURS\"\n }\n },\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"single\": {\n \"timeDuration\": {\n \"duration\": \"24\",\n \"unit\": \"DURATION_UNIT_HOURS\"\n }\n }\n },\n \"sloDefinition\": {\n \"sloId\": \"123e4567-e89b-12d3-a456-426614174000\"\n }\n },\n \"tracingImmediate\": {\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"tracingFilter\": {\n \"simpleFilter\": {\n \"latencyThresholdMs\": \"1000\",\n \"tracingLabelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"operationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"serviceName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"spanFields\": [\n {\n \"filterType\": {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n },\n \"key\": \"span.field.key\"\n }\n ],\n \"subsystemName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ]\n }\n }\n }\n },\n \"tracingThreshold\": {\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"TRACING_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"spanAmount\": 100,\n \"timeWindow\": {\n \"tracingTimeWindowValue\": \"TRACING_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n }\n }\n ],\n \"tracingFilter\": {\n \"simpleFilter\": {\n \"latencyThresholdMs\": \"1000\",\n \"tracingLabelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"operationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"serviceName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"spanFields\": [\n {\n \"filterType\": {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n },\n \"key\": \"span.field.key\"\n }\n ],\n \"subsystemName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ]\n }\n }\n }\n },\n \"type\": \"ALERT_DEF_TYPE_METRIC_THRESHOLD\"\n },\n \"accessPolicy\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.coralogix.com/mgmt/openapi/5/alerts/alerts/v3/all/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"alertDefsToCreate\": [\n {\n \"alertDefProperties\": {\n \"logsImmediate\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ]\n },\n \"activeOn\": {\n \"dayOfWeek\": [\n \"DAY_OF_WEEK_MONDAY_OR_UNSPECIFIED\",\n \"DAY_OF_WEEK_TUESDAY\"\n ],\n \"endTime\": {\n \"hours\": 14,\n \"minutes\": 30\n },\n \"startTime\": {\n \"hours\": 14,\n \"minutes\": 30\n }\n },\n \"analyticsImmediate\": {\n \"dataprimeQuery\": {\n \"query\": \"source logs | filter severity == 'error' | count_agg_key by applicationName\"\n },\n \"evaluationDelayMs\": 300000,\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"timeframeMinutes\": 60,\n \"useRowsAsPermutations\": false\n },\n \"analyticsThreshold\": {\n \"dataprimeQuery\": {\n \"query\": \"source logs | filter severity == 'error' | count_agg_key by applicationName\"\n },\n \"evaluationDelayMs\": 300000,\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"operator\": \"ANALYTICS_THRESHOLD_OPERATOR_MORE_THAN_OR_UNSPECIFIED\",\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 100\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"targetColumn\": \"error_count\",\n \"timeframeMinutes\": 60,\n \"useRowsAsPermutations\": true\n },\n \"dataSources\": [\n {\n \"dataSet\": \"<string>\",\n \"dataSpace\": \"<string>\"\n }\n ],\n \"deleted\": false,\n \"description\": \"Alert description\",\n \"enabled\": true,\n \"entityLabels\": {},\n \"flow\": {\n \"enforceSuppression\": true,\n \"stages\": [\n {\n \"flowStagesGroups\": {\n \"groups\": [\n {\n \"alertDefs\": [\n {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"not\": true\n }\n ],\n \"alertsOp\": \"ALERTS_OP_OR\",\n \"nextOp\": \"NEXT_OP_OR\"\n }\n ]\n },\n \"timeframeMs\": \"<string>\",\n \"timeframeType\": \"TIMEFRAME_TYPE_UP_TO\"\n }\n ]\n },\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"incidentsSettings\": {\n \"minutes\": 30,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n },\n \"logsAnomaly\": {\n \"anomalyAlertSettings\": {\n \"percentageOfDeviation\": 1\n },\n \"evaluationDelayMs\": 60000,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_ANOMALY_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"minimumThreshold\": 10,\n \"timeWindow\": {\n \"logsTimeWindowSpecificValue\": \"LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n }\n }\n ]\n },\n \"logsNewValue\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"keypathToTrack\": \"metadata.field\",\n \"timeWindow\": {\n \"logsNewValueTimeWindowSpecificValue\": \"LOGS_NEW_VALUE_TIME_WINDOW_VALUE_HOURS_12_OR_UNSPECIFIED\"\n }\n }\n }\n ]\n },\n \"logsRatioThreshold\": {\n \"denominator\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"denominatorAlias\": \"denominator_alias\",\n \"evaluationDelayMs\": 60000,\n \"groupByFor\": \"LOGS_RATIO_GROUP_BY_FOR_NUMERATOR_ONLY\",\n \"ignoreInfinity\": true,\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"numerator\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"numeratorAlias\": \"numerator_alias\",\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_RATIO_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 10,\n \"timeWindow\": 10\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"LOGS_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 100,\n \"timeWindow\": {\n \"logsTimeWindowSpecificValue\": \"LOGS_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsTimeRelativeThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"ignoreInfinity\": true,\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"comparedTo\": \"LOGS_TIME_RELATIVE_COMPARED_TO_YESTERDAY\",\n \"conditionType\": \"LOGS_TIME_RELATIVE_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"logsUniqueCount\": {\n \"logsFilter\": {\n \"simpleFilter\": {\n \"labelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ],\n \"severities\": [],\n \"subsystemName\": [\n {\n \"operation\": \"LOG_FILTER_OPERATION_TYPE_INCLUDES\",\n \"value\": \"my-app\"\n }\n ]\n },\n \"luceneQuery\": \"<string>\"\n }\n },\n \"maxUniqueCountPerGroupByKey\": \"100\",\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"maxUniqueCount\": \"100\",\n \"timeWindow\": {\n \"logsUniqueValueTimeWindowSpecificValue\": \"LOGS_UNIQUE_VALUE_TIME_WINDOW_VALUE_HOURS_12\"\n }\n }\n }\n ],\n \"uniqueCountKeypath\": \"obj.field\"\n },\n \"metricAnomaly\": {\n \"anomalyAlertSettings\": {\n \"percentageOfDeviation\": 1\n },\n \"evaluationDelayMs\": 60000,\n \"metricFilter\": {\n \"promql\": \"avg_over_time(metric_name[5m]) > 10\"\n },\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"METRIC_ANOMALY_CONDITION_TYPE_LESS_THAN_USUAL\",\n \"forOverPct\": 20,\n \"minNonNullValuesPct\": 10,\n \"ofTheLast\": {\n \"metricTimeWindowSpecificValue\": \"METRIC_TIME_WINDOW_VALUE_MINUTES_5\",\n \"metricTimeWindowDynamicDuration\": \"1h30m\"\n },\n \"threshold\": 10\n }\n }\n ]\n },\n \"metricThreshold\": {\n \"evaluationDelayMs\": 60000,\n \"metricFilter\": {\n \"promql\": \"avg_over_time(metric_name[5m]) > 10\"\n },\n \"missingValues\": {\n \"replaceWithZero\": true,\n \"minNonNullValuesPct\": 80\n },\n \"noDataPolicy\": {\n \"autoRetireSeconds\": 3600,\n \"state\": \"NO_DATA_POLICY_STATE_ALERTING\"\n },\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"METRIC_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_EQUALS\",\n \"forOverPct\": 80,\n \"ofTheLast\": {\n \"metricTimeWindowSpecificValue\": \"METRIC_TIME_WINDOW_VALUE_MINUTES_5\",\n \"metricTimeWindowDynamicDuration\": \"1h30m\"\n },\n \"threshold\": 100\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"undetectedValuesManagement\": {\n \"autoRetireTimeframe\": \"AUTO_RETIRE_TIMEFRAME_HOURS_24\",\n \"triggerUndetectedValues\": true\n }\n },\n \"name\": \"My Alert\",\n \"notificationGroup\": {\n \"destinations\": [\n {\n \"connectorId\": \"connector_id_example\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\",\n \"presetId\": \"preset_id_example\",\n \"resolvedRouteOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n },\n \"retriggeringPeriodMinutes\": 600,\n \"triggeredRoutingOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n }\n }\n ],\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"router\": {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED\"\n },\n \"webhooks\": [\n {\n \"integration\": {\n \"integrationId\": 123,\n \"recipients\": {\n \"emails\": [\n \"mail@gmail.com\"\n ]\n }\n },\n \"minutes\": 15,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n }\n ]\n },\n \"notificationGroupExcess\": [\n {\n \"destinations\": [\n {\n \"connectorId\": \"connector_id_example\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\",\n \"presetId\": \"preset_id_example\",\n \"resolvedRouteOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n },\n \"retriggeringPeriodMinutes\": 600,\n \"triggeredRoutingOverrides\": {\n \"configOverrides\": {\n \"connectorConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"messageConfigFields\": [\n {\n \"fieldName\": \"description\",\n \"template\": \"template_example\"\n }\n ],\n \"payloadType\": \"slack_raw, slack_structured, pagerduty_triggered, pagerduty_resolved, generic_https_default\"\n }\n }\n }\n ],\n \"groupByKeys\": [\n \"key1\",\n \"key2\"\n ],\n \"router\": {\n \"id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_ONLY_UNSPECIFIED\"\n },\n \"webhooks\": [\n {\n \"integration\": {\n \"integrationId\": 123,\n \"recipients\": {\n \"emails\": [\n \"mail@gmail.com\"\n ]\n }\n },\n \"minutes\": 15,\n \"notifyOn\": \"NOTIFY_ON_TRIGGERED_AND_RESOLVED\"\n }\n ]\n }\n ],\n \"phantomMode\": false,\n \"priority\": \"ALERT_DEF_PRIORITY_P4\",\n \"sloThreshold\": {\n \"errorBudget\": {\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ]\n },\n \"burnRate\": {\n \"dual\": {\n \"timeDuration\": {\n \"duration\": \"24\",\n \"unit\": \"DURATION_UNIT_HOURS\"\n }\n },\n \"rules\": [\n {\n \"condition\": {\n \"threshold\": 1\n },\n \"override\": {\n \"priority\": \"ALERT_DEF_PRIORITY_P3\"\n }\n }\n ],\n \"single\": {\n \"timeDuration\": {\n \"duration\": \"24\",\n \"unit\": \"DURATION_UNIT_HOURS\"\n }\n }\n },\n \"sloDefinition\": {\n \"sloId\": \"123e4567-e89b-12d3-a456-426614174000\"\n }\n },\n \"tracingImmediate\": {\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"tracingFilter\": {\n \"simpleFilter\": {\n \"latencyThresholdMs\": \"1000\",\n \"tracingLabelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"operationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"serviceName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"spanFields\": [\n {\n \"filterType\": {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n },\n \"key\": \"span.field.key\"\n }\n ],\n \"subsystemName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ]\n }\n }\n }\n },\n \"tracingThreshold\": {\n \"notificationPayloadFilter\": [\n \"obj.field\"\n ],\n \"rules\": [\n {\n \"condition\": {\n \"conditionType\": \"TRACING_THRESHOLD_CONDITION_TYPE_MORE_THAN_OR_UNSPECIFIED\",\n \"spanAmount\": 100,\n \"timeWindow\": {\n \"tracingTimeWindowValue\": \"TRACING_TIME_WINDOW_VALUE_MINUTES_5_OR_UNSPECIFIED\"\n }\n }\n }\n ],\n \"tracingFilter\": {\n \"simpleFilter\": {\n \"latencyThresholdMs\": \"1000\",\n \"tracingLabelFilters\": {\n \"applicationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"operationName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"serviceName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ],\n \"spanFields\": [\n {\n \"filterType\": {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n },\n \"key\": \"span.field.key\"\n }\n ],\n \"subsystemName\": [\n {\n \"operation\": \"TRACING_FILTER_OPERATION_TYPE_STARTS_WITH\",\n \"values\": [\n \"value1\",\n \"value2\"\n ]\n }\n ]\n }\n }\n }\n },\n \"type\": \"ALERT_DEF_TYPE_METRIC_THRESHOLD\"\n },\n \"accessPolicy\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"alertDefs": [
{
"alertDefProperties": {
"description": "Fires when the error rate exceeds the threshold.",
"enabled": true,
"name": "High error rate",
"priority": "ALERT_DEF_PRIORITY_P2",
"type": "ALERT_DEF_TYPE_LOGS_THRESHOLD"
},
"alertVersionId": "223e4567-e89b-12d3-a456-426614174000",
"createdTime": "2026-07-01T08:30:00.000Z",
"id": "123e4567-e89b-12d3-a456-426614174000",
"updatedTime": "2026-07-01T08:30:00.000Z"
}
],
"failedToCreateAlertDefs": [
{
"index": 1,
"reason": "Alert definition name must not be empty."
}
]
}{
"code": 349,
"message": "<string>"
}{
"code": 349,
"message": "<string>"
}{
"code": 349,
"message": "<string>"
}Authorizations
API key authentication
Body
A request to create multiple alert definitions
List of alert definitions to create. Limited to 100 alert definitions per request.
1 - 100 elementsShow child attributes
Show child attributes
Response
A response that contains the results of the bulk create operation
List of successfully created alert definitions, returned in the order of their corresponding request entries. Request entries that failed to be created are omitted here and reported by index in failedToCreateAlertDefs.
100Show child attributes
Show child attributes
List of request entries that failed to be created, each identified by its zero-based index in the request list
100Show child attributes
Show child attributes
Was this page helpful?