Messages: count

Description

Calculates the number of messages per period and return the data in the format of 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.

Message Counter 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"}}

Entity Filter Fields

Date Filter Fields

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 \
  --insecure --include --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