Prerequisites
- Create an Axiom account.
- Create a dataset in Axiom where you send your data.
- Create an API token in Axiom with permissions to create, read, update, and delete monitors.
- In the code samples below, replace
API_TOKENwith the Axiom API token you have generated. For added security, store the API token in an environment variable.
Create threshold monitors
To create a threshold monitor, send a POST request to themonitors endpoint. In the body of the request, specify the following:
nameof your monitor.aplQueryis the APL query that the monitor periodically runs to aggregate data. Axiom alerts you when the results from your query cross the threshold.thresholdis the value to compare the results of the query to. This can be any numeric value.operatoris the rule to apply when comparing the results to the threshold. The possible values areBelow,BelowOrEqual,Above, andAboveOrEqual.intervalMinutesis how often the monitor runs. This is a positive integer number of minutes.rangeMinutesis the time range for your query. This is a positive integer number of minutes. The end time is the time the monitor runs.alertOnNoDatatriggers the monitor when your query doesn’t return any data. Your query returns no data if no events match your filters and an aggregation used in the query is undefined. For example, you take the average of a field not present in any matching events.
descriptionexplains what your monitor does.notifierIdsis a list of notifier IDs. The related notifiers define how you want to receive notifications for this monitor. For more information, see Manage notifiers.- You can group by attributes when defining your query. By default, your monitor enters the alert state if any of the values returned for the group-by attributes cross the threshold, and remains in the alert state until none of the values returned cross the threshold. To trigger the monitor separately for each group that crosses the threshold, set
notifyByGroupto true. At most one trigger notification is sent per monitor run. This option only has an effect if the monitor’s query groups by a non-time field.
Replace
AXIOM_DOMAIN with api.axiom.co if your organization uses the US region, and with api.eu.axiom.co if your organization uses the EU region. For more information, see Regions.Replace API_TOKEN with the Axiom API token you have generated. For added security, store the API token in an environment variable.Get information about monitors
Get information about all monitors
To get information about all the monitors in your Axiom organization, send a GET request to themonitors endpoint. For example:
Replace
AXIOM_DOMAIN with api.axiom.co if your organization uses the US region, and with api.eu.axiom.co if your organization uses the EU region. For more information, see Regions.Replace API_TOKEN with the Axiom API token you have generated. For added security, store the API token in an environment variable.Get information about specific monitor
To get information about a specific monitor, send a GET request to themonitors/MONITOR_ID endpoint where MONITOR_ID is the unique ID of the monitor. For example:
Replace
AXIOM_DOMAIN with api.axiom.co if your organization uses the US region, and with api.eu.axiom.co if your organization uses the EU region. For more information, see Regions.Replace API_TOKEN with the Axiom API token you have generated. For added security, store the API token in an environment variable.Update monitors
To update a monitor, send a PUT request to themonitors/MONITOR_ID endpoint where MONITOR_ID is the unique ID of the monitor. In the body of the request, specify the properties you want to update. For example:
Replace
AXIOM_DOMAIN with api.axiom.co if your organization uses the US region, and with api.eu.axiom.co if your organization uses the EU region. For more information, see Regions.Replace API_TOKEN with the Axiom API token you have generated. For added security, store the API token in an environment variable.Delete monitors
To delete a monitor, send a DELETE request to themonitors/MONITOR_ID endpoint where MONITOR_ID is the unique ID of the monitor. For example:
Replace
AXIOM_DOMAIN with api.axiom.co if your organization uses the US region, and with api.eu.axiom.co if your organization uses the EU region. For more information, see Regions.Replace API_TOKEN with the Axiom API token you have generated. For added security, store the API token in an environment variable.