Skip to main content
POST
/
events
/
count-by
/
{countable}
Count Account Events
curl --request POST \
  --url https://api.example.com/events/count-by/{countable} \
  --header 'Content-Type: application/json' \
  --data '
{
  "filter": {
    "occurred": {
      "since": "2023-11-07T05:31:56Z",
      "until": "2023-11-07T05:31:56Z"
    },
    "event": {
      "prefix": [
        "<string>"
      ],
      "exclude_prefix": [
        "<string>"
      ],
      "name": [
        "<string>"
      ],
      "exclude_name": [
        "<string>"
      ]
    },
    "resource": {
      "id": [
        "<string>"
      ],
      "id_prefix": [
        "<string>"
      ],
      "labels": {},
      "distinct": false
    },
    "related": {
      "id": [
        "<string>"
      ],
      "role": [
        "<string>"
      ],
      "resources_in_roles": [
        [
          "<string>",
          "<string>"
        ]
      ],
      "labels": {}
    },
    "any_resource": {
      "id": [
        "<string>"
      ],
      "id_prefix": [
        "<string>"
      ],
      "labels": {}
    },
    "id": {
      "id": [
        "3c90c3cc-0d44-4b50-8888-8dd25736052a"
      ]
    },
    "text": {
      "query": "<string>"
    },
    "order": "DESC"
  },
  "time_unit": "day",
  "time_interval": 1
}
'
import requests

url = "https://api.example.com/events/count-by/{countable}"

payload = {
    "filter": {
        "occurred": {
            "since": "2023-11-07T05:31:56Z",
            "until": "2023-11-07T05:31:56Z"
        },
        "event": {
            "prefix": ["<string>"],
            "exclude_prefix": ["<string>"],
            "name": ["<string>"],
            "exclude_name": ["<string>"]
        },
        "resource": {
            "id": ["<string>"],
            "id_prefix": ["<string>"],
            "labels": {},
            "distinct": False
        },
        "related": {
            "id": ["<string>"],
            "role": ["<string>"],
            "resources_in_roles": [["<string>", "<string>"]],
            "labels": {}
        },
        "any_resource": {
            "id": ["<string>"],
            "id_prefix": ["<string>"],
            "labels": {}
        },
        "id": { "id": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"] },
        "text": { "query": "<string>" },
        "order": "DESC"
    },
    "time_unit": "day",
    "time_interval": 1
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    filter: {
      occurred: {since: '2023-11-07T05:31:56Z', until: '2023-11-07T05:31:56Z'},
      event: {
        prefix: ['<string>'],
        exclude_prefix: ['<string>'],
        name: ['<string>'],
        exclude_name: ['<string>']
      },
      resource: {id: ['<string>'], id_prefix: ['<string>'], labels: {}, distinct: false},
      related: {
        id: ['<string>'],
        role: ['<string>'],
        resources_in_roles: [['<string>', '<string>']],
        labels: {}
      },
      any_resource: {id: ['<string>'], id_prefix: ['<string>'], labels: {}},
      id: {id: ['3c90c3cc-0d44-4b50-8888-8dd25736052a']},
      text: {query: '<string>'},
      order: 'DESC'
    },
    time_unit: 'day',
    time_interval: 1
  })
};

fetch('https://api.example.com/events/count-by/{countable}', 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.example.com/events/count-by/{countable}",
  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([
    'filter' => [
        'occurred' => [
                'since' => '2023-11-07T05:31:56Z',
                'until' => '2023-11-07T05:31:56Z'
        ],
        'event' => [
                'prefix' => [
                                '<string>'
                ],
                'exclude_prefix' => [
                                '<string>'
                ],
                'name' => [
                                '<string>'
                ],
                'exclude_name' => [
                                '<string>'
                ]
        ],
        'resource' => [
                'id' => [
                                '<string>'
                ],
                'id_prefix' => [
                                '<string>'
                ],
                'labels' => [
                                
                ],
                'distinct' => false
        ],
        'related' => [
                'id' => [
                                '<string>'
                ],
                'role' => [
                                '<string>'
                ],
                'resources_in_roles' => [
                                [
                                                                '<string>',
                                                                '<string>'
                                ]
                ],
                'labels' => [
                                
                ]
        ],
        'any_resource' => [
                'id' => [
                                '<string>'
                ],
                'id_prefix' => [
                                '<string>'
                ],
                'labels' => [
                                
                ]
        ],
        'id' => [
                'id' => [
                                '3c90c3cc-0d44-4b50-8888-8dd25736052a'
                ]
        ],
        'text' => [
                'query' => '<string>'
        ],
        'order' => 'DESC'
    ],
    'time_unit' => 'day',
    'time_interval' => 1
  ]),
  CURLOPT_HTTPHEADER => [
    "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.example.com/events/count-by/{countable}"

	payload := strings.NewReader("{\n  \"filter\": {\n    \"occurred\": {\n      \"since\": \"2023-11-07T05:31:56Z\",\n      \"until\": \"2023-11-07T05:31:56Z\"\n    },\n    \"event\": {\n      \"prefix\": [\n        \"<string>\"\n      ],\n      \"exclude_prefix\": [\n        \"<string>\"\n      ],\n      \"name\": [\n        \"<string>\"\n      ],\n      \"exclude_name\": [\n        \"<string>\"\n      ]\n    },\n    \"resource\": {\n      \"id\": [\n        \"<string>\"\n      ],\n      \"id_prefix\": [\n        \"<string>\"\n      ],\n      \"labels\": {},\n      \"distinct\": false\n    },\n    \"related\": {\n      \"id\": [\n        \"<string>\"\n      ],\n      \"role\": [\n        \"<string>\"\n      ],\n      \"resources_in_roles\": [\n        [\n          \"<string>\",\n          \"<string>\"\n        ]\n      ],\n      \"labels\": {}\n    },\n    \"any_resource\": {\n      \"id\": [\n        \"<string>\"\n      ],\n      \"id_prefix\": [\n        \"<string>\"\n      ],\n      \"labels\": {}\n    },\n    \"id\": {\n      \"id\": [\n        \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n      ]\n    },\n    \"text\": {\n      \"query\": \"<string>\"\n    },\n    \"order\": \"DESC\"\n  },\n  \"time_unit\": \"day\",\n  \"time_interval\": 1\n}")

	req, _ := http.NewRequest("POST", url, payload)

	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.example.com/events/count-by/{countable}")
  .header("Content-Type", "application/json")
  .body("{\n  \"filter\": {\n    \"occurred\": {\n      \"since\": \"2023-11-07T05:31:56Z\",\n      \"until\": \"2023-11-07T05:31:56Z\"\n    },\n    \"event\": {\n      \"prefix\": [\n        \"<string>\"\n      ],\n      \"exclude_prefix\": [\n        \"<string>\"\n      ],\n      \"name\": [\n        \"<string>\"\n      ],\n      \"exclude_name\": [\n        \"<string>\"\n      ]\n    },\n    \"resource\": {\n      \"id\": [\n        \"<string>\"\n      ],\n      \"id_prefix\": [\n        \"<string>\"\n      ],\n      \"labels\": {},\n      \"distinct\": false\n    },\n    \"related\": {\n      \"id\": [\n        \"<string>\"\n      ],\n      \"role\": [\n        \"<string>\"\n      ],\n      \"resources_in_roles\": [\n        [\n          \"<string>\",\n          \"<string>\"\n        ]\n      ],\n      \"labels\": {}\n    },\n    \"any_resource\": {\n      \"id\": [\n        \"<string>\"\n      ],\n      \"id_prefix\": [\n        \"<string>\"\n      ],\n      \"labels\": {}\n    },\n    \"id\": {\n      \"id\": [\n        \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n      ]\n    },\n    \"text\": {\n      \"query\": \"<string>\"\n    },\n    \"order\": \"DESC\"\n  },\n  \"time_unit\": \"day\",\n  \"time_interval\": 1\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.example.com/events/count-by/{countable}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"filter\": {\n    \"occurred\": {\n      \"since\": \"2023-11-07T05:31:56Z\",\n      \"until\": \"2023-11-07T05:31:56Z\"\n    },\n    \"event\": {\n      \"prefix\": [\n        \"<string>\"\n      ],\n      \"exclude_prefix\": [\n        \"<string>\"\n      ],\n      \"name\": [\n        \"<string>\"\n      ],\n      \"exclude_name\": [\n        \"<string>\"\n      ]\n    },\n    \"resource\": {\n      \"id\": [\n        \"<string>\"\n      ],\n      \"id_prefix\": [\n        \"<string>\"\n      ],\n      \"labels\": {},\n      \"distinct\": false\n    },\n    \"related\": {\n      \"id\": [\n        \"<string>\"\n      ],\n      \"role\": [\n        \"<string>\"\n      ],\n      \"resources_in_roles\": [\n        [\n          \"<string>\",\n          \"<string>\"\n        ]\n      ],\n      \"labels\": {}\n    },\n    \"any_resource\": {\n      \"id\": [\n        \"<string>\"\n      ],\n      \"id_prefix\": [\n        \"<string>\"\n      ],\n      \"labels\": {}\n    },\n    \"id\": {\n      \"id\": [\n        \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n      ]\n    },\n    \"text\": {\n      \"query\": \"<string>\"\n    },\n    \"order\": \"DESC\"\n  },\n  \"time_unit\": \"day\",\n  \"time_interval\": 1\n}"

response = http.request(request)
puts response.read_body
[
  {
    "value": "<string>",
    "label": "<string>",
    "count": 123,
    "start_time": "2023-11-07T05:31:56Z",
    "end_time": "2023-11-07T05:31:56Z"
  }
]
{
  "detail": [
    {
      "loc": [
        "<string>"
      ],
      "msg": "<string>",
      "type": "<string>",
      "input": "<unknown>",
      "ctx": {}
    }
  ]
}

Headers

x-prefect-api-version
string

Path Parameters

countable
enum<string>
required
Available options:
day,
time,
event,
resource

Body

application/json
filter
EventFilter · object
required
time_unit
enum<string>
default:day
Available options:
week,
day,
hour,
minute,
second
time_interval
number
default:1
Required range: x >= 0.01

Response

Successful Response

value
string
required

The value to use for filtering

label
string
required

The value to display for this count

count
integer
required

The count of matching events

start_time
string<date-time>
required

The start time of this group of events

end_time
string<date-time>
required

The end time of this group of events