This article provides details on how to create auto tag rules using a global query.
Currently, auto tagging using a global query can be achieved using API only. GUI based solution will be available in release 77.
upt_asset_id and tag column from the global query determine the assets to be assigned with a particular tag.
Use interval for scheduled tags rules
Use runOnce for one time tag rules.
Scheduled auto tag rule based on Global query
{
"name": 'Mac osx auto tag rule Global',
"description": 'Tag all whoose os_version is mac os x',
"query": "with latest_row as (
select
name,
upt_assets.upt_asset_id,
max(os_version.upt_time) as maxtime
from
os_version
inner join upt_assets on os_version.upt_asset_id = upt_assets.id
where
upt_day >= CAST(
date_format(
localtimestamp - INTERVAL '3' DAY, '%Y%m%d'
) AS INTEGER
)
group by
name,
upt_assets.upt_asset_id
)
select
distinct upt_asset_id,
'usmacbook' as tag
from
latest_row
where
name = 'Mac OS X'",
"interval": 3600,
"source": 'global'
}
One time tag rule
{
"name": 'Mac osx auto tag rule Global',
"description": 'Tag all whoose os_version is mac os x',
"query": "with latest_row as (
select
name,
upt_assets.upt_asset_id,
max(os_version.upt_time) as maxtime
from
os_version
inner join upt_assets on os_version.upt_asset_id = upt_assets.id
where
upt_day >= CAST(
date_format(
localtimestamp - INTERVAL '3' DAY, '%Y%m%d'
) AS INTEGER
)
group by
name,
upt_assets.upt_asset_id
)
select
distinct upt_asset_id,
'usmacbook' as tag
from
latest_row
where
name = 'Mac OS X'",
"runOnce": true,
"source": 'global'
}