Tagging datastreams in Management API
On this page
This guide explains how to create datastream tags, add them to and remove them from datastreams in bulk, read them back, and filter datastreams by tag using the Management API.
See GET /api/v1/datastream-tags/, POST /api/v1/datastream-tags/ and POST /api/v1/datastreams/tags/ in the API reference.
Introduction
- What is a datastream tag?
A tag is a short label, such as
prodordaily, that you attach to datastreams to group them, for example to select them in an external orchestrator.- Which workspace does a tag belong to?
Every tag belongs to exactly one workspace. Its name is unique within that workspace, ignoring case. The same name in another workspace, including a parent or child workspace, is a separate tag.
- Which tags can a datastream carry?
A datastream only carries tags of its own workspace. Anyone who can see the datastream can see its tags.
- What happens when a datastream is copied or moved?
Its tags follow it. In another workspace, each tag is matched by name to a tag of that workspace, and created there if it does not exist yet.
- Where do tag changes appear?
Adding, removing, and deleting tags appears in the History tab of each affected datastream, with the tag names before and after the change.
Prerequisites
Obtain a Management API key with the appropriate scope:
-
datastream: readto list tags, read the tags of datastreams, and filter datastreams by tag. -
datastream: writeto create, rename, and delete tags, and to add them to or remove them from datastreams.
An existing key may not have these scopes, even if it works with the legacy endpoints. For how to check a key and what to do if it lacks them, see Authentication and scopes in v1.
The key can only see and change tags of the workspaces it has access to. For more information, see Authorizing to Management API.
Limitations
Scroll horizontally to see the full table.
What | Limit |
|---|---|
Tag name | 25 characters |
Tags per datastream | 50 |
Tags per bulk request | 50 |
datastreams per bulk request | 500, whether they are listed in |
Requests that exceed the per-request list limits return an HTTP 422 error. A bulk request that matches more than 500 datastreams through its query parameters returns an HTTP 400 error.
Creating a tag
To create a tag, follow these steps:
-
Create a POST request to the following endpoint:
https://{{INSTANCE}}/api/v1/datastream-tags/ -
In the HTTP request header, include the
Authorization: Bearer {{KEY}}parameter. -
In the HTTP request header, include the parameter
Content-Typewith valueapplication/json. -
In the HTTP request body, include the following parameters:
Scroll horizontally to see the full table.
Parameter
Required
Description
workspace_idYes
The UUID of the workspace that owns the tag.
nameYes
The tag name. Up to 25 characters. Leading and trailing spaces are removed.
-
Send the request.
As a result, Adverity creates the tag and returns it with HTTP 201. If the workspace already has a tag with the same name, ignoring case, the response is HTTP 409 and contains the existing tag in tag.
The cURL request example is the following:
curl --location --request POST 'https://{{INSTANCE}}/api/v1/datastream-tags/' \
--header 'Authorization: Bearer {{KEY}}' \
--header 'Content-Type: application/json' \
--data '{"workspace_id": "{{WORKSPACE_ID}}", "name": "prod"}'
A tag in the response contains the following fields:
Scroll horizontally to see the full table.
Field | Description |
|---|---|
| The UUID of the tag. |
| The tag name. |
| The |
| When the tag was created. |
The response to a create request also contains same_name_in_ancestor_workspaces: the parent workspaces, among those the key can see, that already have a tag with this name. Those are separate tags.
Renaming a tag
To rename a tag, follow these steps:
-
Create a PATCH request to the following endpoint:
https://{{INSTANCE}}/api/v1/datastream-tags/{{TAG_ID}}/ -
In the HTTP request header, include the
Authorization: Bearer {{KEY}}parameter. -
In the HTTP request header, include the parameter
Content-Typewith valueapplication/json. -
In the HTTP request body, include
namewith the new tag name. -
Send the request.
As a result, every datastream that carries the tag shows the new name. Earlier entries in the History tab keep the old name. If another tag of the same workspace has the new name, the response is HTTP 409. Changing only the case of the name is allowed. The workspace of a tag cannot change.
Deleting a tag
To delete a tag, follow these steps:
-
Create a DELETE request to the following endpoint:
https://{{INSTANCE}}/api/v1/datastream-tags/{{TAG_ID}}/ -
In the HTTP request header, include the
Authorization: Bearer {{KEY}}parameter. -
Send the request.
As a result, Adverity deletes the tag and removes it from every datastream that carried it. The response field removed_from_datastreams contains the number of datastreams the tag was removed from.
Filtering datastreams by tag
Each item of GET https://{{INSTANCE}}/api/v1/datastreams/ contains a tags list with the id and name of each tag. To list only datastreams with certain tags, add the following query parameters:
Scroll horizontally to see the full table.
Parameter | Description |
|---|---|
| A tag name, ignoring case. Repeat it for several names. It matches the name in every workspace the key can see. To match the tag of one workspace only, add |
|
|
You can combine them with the other query parameters of the list. For all of them, see Listing datastreams in Management API.
The cURL request example is the following:
curl --location --request GET 'https://{{INSTANCE}}/api/v1/datastreams/?tag=prod&tag=daily&tag_match=all' \
--header 'Authorization: Bearer {{KEY}}'
The same query parameters also target the bulk datastream update, the smart schedule update, and the custom monitor assignment requests. For more information, see Managing pulling mode and smart schedule in Management API and Bulk assigning custom monitors in Management API.