Auto deletion or management of TrackMe entities

Introduction to automated management of TrackMe entities

About this paper:

  • In some use cases, you may want to automatically manage entities in TrackMe based on different criterias.

  • For instance, if you track hosts in TrackMe, you could for example automatically delete machines that have been tagged as decommissioned in your CMDB.

  • This way, you would automatically keep your TrackMe entities in sync with your CMDB and purge entities as needed.

Alternative using the Flex object component (splk-flex)

Licensed TrackMe users can also leverage instead the Flex object component to track hosts, the same logic can be used very easily too:

| trackmegetcoll tenant_id=hosts-flx-tracking component=flx
| table keyid, object, alias, object_state, object_description

``` select entities in alert ```
| where object_state="red"

``` cross with your CMDB ```
| lookup my_hosts_cmdb ci_id as alias OUTPUT ci_status
| where isnotnull(ci_status) AND ci_status!=""

``` build the keyid comma separated list ```
| stats values(keyid) as keyid
| eval keyid=mvjoin(keyid, ",")

``` call map and the TrackMe entities deletion endpoint ```
| map search="| trackme url=\"/services/trackme/v2/splk_flx/write/flx_delete\" mode=\"post\" body=\"{'tenant_id':'hosts-flx-tracking', 'deletion_type': 'temporary', 'keys_list':'$keyid$', 'comment_update': 'This host was detected as decommissioned in the CMDB and automatically purged.'}\""

Alternative logic disabling rather then deleting entities

Alternatively, we may want to disable entities, rather than deleting them, the same logic would apply and we would simply call a different endpoint.

With our splk-dhm example:

| trackmegetcoll tenant_id=host-dhm-tracking component=dhm
| table keyid, object, alias, object_state

``` select entities in alert ```
| where object_state="red"

``` cross with your CMDB ```
| lookup my_hosts_cmdb ci_id as alias OUTPUT ci_status
| where isnotnull(ci_status) AND ci_status!=""

``` build the keyid comma separated list ```
| stats values(keyid) as keyid
| eval keyid=mvjoin(keyid, ",")

``` call map and the TrackMe entities deletion endpoint ```
| map search="| trackme url=\"/services/trackme/v2/splk_dhm/write/dh_monitoring\" mode=\"post\" body=\"{'tenant_id':'host-dhm-tracking', 'action': 'disable', 'keys_list':'$keyid$', 'comment_update': 'This host was detected as decommissioned in the CMDB and automatically disabled.'}\""

With our splk-flx example:

| trackmegetcoll tenant_id=host-flx-tracking component=dhm
| table keyid, object, alias, object_state

``` select entities in alert ```
| where object_state="red"

``` cross with your CMDB ```
| lookup my_hosts_cmdb ci_id as alias OUTPUT ci_status
| where isnotnull(ci_status) AND ci_status!=""

``` build the keyid comma separated list ```
| stats values(keyid) as keyid
| eval keyid=mvjoin(keyid, ",")

``` call map and the TrackMe entities deletion endpoint ```
| map search="| trackme url=\"/services/trackme/v2/splk_dhm/write/flx_monitoring\" mode=\"post\" body=\"{'tenant_id':'host-flx-tracking', 'action': 'disable', 'keys_list':'$keyid$', 'comment_update': 'This host was detected as decommissioned in the CMDB and automatically disabled.'}\""

Hint

The same type of logic applies to anything in TrackMe:

  • In fact, you totally can use the same type of logic in many variations, whatever the component you are dealing with.

  • You can for example decide to have entities with a monitored state defined as disabled when entities are discovered, then wait for at least 7 days of historical knowledge to be collected before enabling the monitoring, or any other concept that makes sense for your context.

  • Consult the REST API reference dashboard in TrackMe, menu API & Tooling to find which endpoints are available for each component, as well as their usage and usage examples.

rest_api_ref.png rest_api_ref2.png