Messages: stats
Description
Calculates the number of messages per period and returns the data in the same format as series
query.
If period aggregation is enabled, the series contains the number of messages in each period. Otherwise, the series contains the total number of messages within the specified interval.
Request
Method | Path | Content-Type Header |
---|---|---|
POST | /api/v1/messages/stats/query | application/json |
Parameters
None.
Fields
An array of query objects containing the following filtering fields:
Message Filter Fields
Refer to message query fields.
Calculation Fields
Name | Type | Description |
---|---|---|
metric | string | [Required] Must be set to message-count . |
groupKeys | array | Array of message tags used for grouping: type , source , entity , etc, for example "groupKeys": ["entity", "type"] |
aggregate | object | Period aggregator. Only COUNT type is supported. "aggregate":{"type":"COUNT", "period":{"count":1,"unit":"HOUR"}} |
tagExpression | string | Expression to filter messages with access to fields: message , type , source , severity , and tags.<name> . |
Entity Filter Fields
- [Required]
- Refer to entity filter.
Date Filter Fields
- [Required]
- Refer to date filter.
Control Fields
Name | Type | Description |
---|---|---|
requestId | string | Optional identifier used to associate query object in request with series objects in response. |
timeFormat | string | Time format for data array. iso or milliseconds . Default: iso . |
Response
An array of series
objects containing message filter fields and message counter fields.
Tags used for grouping are returned in the tags
object.
Fields
Refer to series fields.
Errors
None.
Example
Request
URI
POST /api/v1/messages/stats/query
Payload
[{
"entity" : "nurswgvml007",
"metric" : "message-count",
"groupKeys" : ["type"],
"aggregate" : {
"type" : "COUNT",
"period" : {
"count" : 1,
"unit" : "HOUR"
}
},
"startDate" : "current_day",
"endDate" : "now"
}
]
curl
curl https://atsd_hostname:8443/api/v1/messages/stats/query \
-k --user {username}:{password} \
--header "Content-Type: application/json" \
--data @file.json
Response
Payload
[
{
"entity": "nurswgvml007",
"metric": "message-count",
"tags":
{
"type": "application"
},
"type": "HISTORY",
"aggregate":
{
"type": "COUNT",
"period":
{
"count": 1,
"unit": "HOUR"
}
},
"data":
[
{
"d": "2016-05-31T06:00:00.000Z",
"v": 1
}
]
},
{
"entity": "nurswgvml007",
"metric": "message-count",
"tags":
{
"type": "backup"
},
"type": "HISTORY",
"aggregate":
{
"type": "COUNT",
"period":
{
"count": 1,
"unit": "HOUR"
}
},
"data":
[
{
"d": "2016-05-31T03:00:00.000Z",
"v": 4
}
]
},
{
"entity": "nurswgvml007",
"metric": "message-count",
"tags":
{
"type": "security"
},
"type": "HISTORY",
"aggregate":
{
"type": "COUNT",
"period":
{
"count": 1,
"unit": "HOUR"
}
},
"data":
[
{
"d": "2016-05-31T00:00:00.000Z",
"v": 32
},
{
"d": "2016-05-31T07:00:00.000Z",
"v": 30
},
{
"d": "2016-05-31T09:00:00.000Z",
"v": 2
},
{
"d": "2016-05-31T10:00:00.000Z",
"v": 30
},
{
"d": "2016-05-31T12:00:00.000Z",
"v": 16
}
]
}
]
Additional Examples
- Counting all Messages for an Entity
- Multiple Entities Counted as 1 Series, no Grouping
- Entity Array with Message Counts Grouped by Entity
- Message Counts Grouped by Multiple Fields
- Message Counts Grouped by Type
- Message Count per Period
- Interpolate Counts for Missing Periods with 0 value
- Milliseconds
timeFormat
- Multiple Queries for Different Message Types