Metrics endpoints
Detect anomalies in a metrics timeseries
Runs a trend, spike, changepoint, time-to-threshold, or rate detector on a metrics timeseries. Returns the series and any detections.
POST
/
api
/
v2
/
metrics
/
anomaly
Detect anomalies in a metrics timeseries
curl --request POST \
--url https://appsignal.com/api/v2/metrics/anomaly \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": {
"site_id": "abc123",
"from": "2024-01-01T00:00:00Z",
"to": "2024-01-08T00:00:00Z",
"resolution": "HOURLY",
"select": [
{
"name": "disk_usage",
"field": "GAUGE",
"tags": {
"hostname": "server-1"
}
}
]
},
"detector": "trend",
"config": {
"ceiling": 100
}
}
'import requests
url = "https://appsignal.com/api/v2/metrics/anomaly"
payload = {
"query": {
"site_id": "abc123",
"from": "2024-01-01T00:00:00Z",
"to": "2024-01-08T00:00:00Z",
"resolution": "HOURLY",
"select": [
{
"name": "disk_usage",
"field": "GAUGE",
"tags": { "hostname": "server-1" }
}
]
},
"detector": "trend",
"config": { "ceiling": 100 }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: {
site_id: 'abc123',
from: '2024-01-01T00:00:00Z',
to: '2024-01-08T00:00:00Z',
resolution: 'HOURLY',
select: [{name: 'disk_usage', field: 'GAUGE', tags: {hostname: 'server-1'}}]
},
detector: 'trend',
config: {ceiling: 100}
})
};
fetch('https://appsignal.com/api/v2/metrics/anomaly', 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://appsignal.com/api/v2/metrics/anomaly",
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([
'query' => [
'site_id' => 'abc123',
'from' => '2024-01-01T00:00:00Z',
'to' => '2024-01-08T00:00:00Z',
'resolution' => 'HOURLY',
'select' => [
[
'name' => 'disk_usage',
'field' => 'GAUGE',
'tags' => [
'hostname' => 'server-1'
]
]
]
],
'detector' => 'trend',
'config' => [
'ceiling' => 100
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://appsignal.com/api/v2/metrics/anomaly"
payload := strings.NewReader("{\n \"query\": {\n \"site_id\": \"abc123\",\n \"from\": \"2024-01-01T00:00:00Z\",\n \"to\": \"2024-01-08T00:00:00Z\",\n \"resolution\": \"HOURLY\",\n \"select\": [\n {\n \"name\": \"disk_usage\",\n \"field\": \"GAUGE\",\n \"tags\": {\n \"hostname\": \"server-1\"\n }\n }\n ]\n },\n \"detector\": \"trend\",\n \"config\": {\n \"ceiling\": 100\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://appsignal.com/api/v2/metrics/anomaly")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": {\n \"site_id\": \"abc123\",\n \"from\": \"2024-01-01T00:00:00Z\",\n \"to\": \"2024-01-08T00:00:00Z\",\n \"resolution\": \"HOURLY\",\n \"select\": [\n {\n \"name\": \"disk_usage\",\n \"field\": \"GAUGE\",\n \"tags\": {\n \"hostname\": \"server-1\"\n }\n }\n ]\n },\n \"detector\": \"trend\",\n \"config\": {\n \"ceiling\": 100\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://appsignal.com/api/v2/metrics/anomaly")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": {\n \"site_id\": \"abc123\",\n \"from\": \"2024-01-01T00:00:00Z\",\n \"to\": \"2024-01-08T00:00:00Z\",\n \"resolution\": \"HOURLY\",\n \"select\": [\n {\n \"name\": \"disk_usage\",\n \"field\": \"GAUGE\",\n \"tags\": {\n \"hostname\": \"server-1\"\n }\n }\n ]\n },\n \"detector\": \"trend\",\n \"config\": {\n \"ceiling\": 100\n }\n}"
response = http.request(request)
puts response.read_body{
"series": {
"resolution": "HOURLY",
"from": "2023-11-07T05:31:56Z",
"to": "2023-11-07T05:31:56Z",
"series": [
{
"id": "<string>",
"name": "<string>",
"tags": {},
"max": 123,
"min": 123,
"field": "GAUGE",
"data": [
{
"timestamp": "2023-11-07T05:31:56Z",
"value": 123
}
]
}
]
},
"detections": [
{
"kind": "trend",
"series_id": "<string>",
"score": 123,
"severity": "info",
"explanation": "<string>",
"projection": {
"slope_per_second": 123,
"fit_quality": 123,
"ceiling": 123,
"cross_at": 123,
"seconds_to_cross": 123
},
"points": [
{
"at": 123,
"value": 123,
"z_score": 123,
"baseline": 123
}
]
}
]
}{
"error": "<string>",
"message": "<string>",
"details": "<unknown>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>",
"suggestion": "<string>"
}{
"error": "<string>"
}The
query field takes a timeseries query. For selectors and fields, see Querying metrics.
Body
application/json
The series to analyse, the detector to run and its tuning.
Response
The fetched series and its detections.
Was this page helpful?
⌘I
Detect anomalies in a metrics timeseries
curl --request POST \
--url https://appsignal.com/api/v2/metrics/anomaly \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": {
"site_id": "abc123",
"from": "2024-01-01T00:00:00Z",
"to": "2024-01-08T00:00:00Z",
"resolution": "HOURLY",
"select": [
{
"name": "disk_usage",
"field": "GAUGE",
"tags": {
"hostname": "server-1"
}
}
]
},
"detector": "trend",
"config": {
"ceiling": 100
}
}
'import requests
url = "https://appsignal.com/api/v2/metrics/anomaly"
payload = {
"query": {
"site_id": "abc123",
"from": "2024-01-01T00:00:00Z",
"to": "2024-01-08T00:00:00Z",
"resolution": "HOURLY",
"select": [
{
"name": "disk_usage",
"field": "GAUGE",
"tags": { "hostname": "server-1" }
}
]
},
"detector": "trend",
"config": { "ceiling": 100 }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: {
site_id: 'abc123',
from: '2024-01-01T00:00:00Z',
to: '2024-01-08T00:00:00Z',
resolution: 'HOURLY',
select: [{name: 'disk_usage', field: 'GAUGE', tags: {hostname: 'server-1'}}]
},
detector: 'trend',
config: {ceiling: 100}
})
};
fetch('https://appsignal.com/api/v2/metrics/anomaly', 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://appsignal.com/api/v2/metrics/anomaly",
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([
'query' => [
'site_id' => 'abc123',
'from' => '2024-01-01T00:00:00Z',
'to' => '2024-01-08T00:00:00Z',
'resolution' => 'HOURLY',
'select' => [
[
'name' => 'disk_usage',
'field' => 'GAUGE',
'tags' => [
'hostname' => 'server-1'
]
]
]
],
'detector' => 'trend',
'config' => [
'ceiling' => 100
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://appsignal.com/api/v2/metrics/anomaly"
payload := strings.NewReader("{\n \"query\": {\n \"site_id\": \"abc123\",\n \"from\": \"2024-01-01T00:00:00Z\",\n \"to\": \"2024-01-08T00:00:00Z\",\n \"resolution\": \"HOURLY\",\n \"select\": [\n {\n \"name\": \"disk_usage\",\n \"field\": \"GAUGE\",\n \"tags\": {\n \"hostname\": \"server-1\"\n }\n }\n ]\n },\n \"detector\": \"trend\",\n \"config\": {\n \"ceiling\": 100\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://appsignal.com/api/v2/metrics/anomaly")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": {\n \"site_id\": \"abc123\",\n \"from\": \"2024-01-01T00:00:00Z\",\n \"to\": \"2024-01-08T00:00:00Z\",\n \"resolution\": \"HOURLY\",\n \"select\": [\n {\n \"name\": \"disk_usage\",\n \"field\": \"GAUGE\",\n \"tags\": {\n \"hostname\": \"server-1\"\n }\n }\n ]\n },\n \"detector\": \"trend\",\n \"config\": {\n \"ceiling\": 100\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://appsignal.com/api/v2/metrics/anomaly")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": {\n \"site_id\": \"abc123\",\n \"from\": \"2024-01-01T00:00:00Z\",\n \"to\": \"2024-01-08T00:00:00Z\",\n \"resolution\": \"HOURLY\",\n \"select\": [\n {\n \"name\": \"disk_usage\",\n \"field\": \"GAUGE\",\n \"tags\": {\n \"hostname\": \"server-1\"\n }\n }\n ]\n },\n \"detector\": \"trend\",\n \"config\": {\n \"ceiling\": 100\n }\n}"
response = http.request(request)
puts response.read_body{
"series": {
"resolution": "HOURLY",
"from": "2023-11-07T05:31:56Z",
"to": "2023-11-07T05:31:56Z",
"series": [
{
"id": "<string>",
"name": "<string>",
"tags": {},
"max": 123,
"min": 123,
"field": "GAUGE",
"data": [
{
"timestamp": "2023-11-07T05:31:56Z",
"value": 123
}
]
}
]
},
"detections": [
{
"kind": "trend",
"series_id": "<string>",
"score": 123,
"severity": "info",
"explanation": "<string>",
"projection": {
"slope_per_second": 123,
"fit_quality": 123,
"ceiling": 123,
"cross_at": 123,
"seconds_to_cross": 123
},
"points": [
{
"at": 123,
"value": 123,
"z_score": 123,
"baseline": 123
}
]
}
]
}{
"error": "<string>",
"message": "<string>",
"details": "<unknown>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>",
"suggestion": "<string>"
}{
"error": "<string>"
}