The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WebService::DataDog::Tag - Interface to Tag functions in DataDog's API.

VERSION

Version 1.0.0

SYNOPSIS

This module allows you interact with the Tag endpoint of the DataDog API.

Per DataDog: "The tag end point allows you to tag hosts with keywords meaningful to you - like role:database. All metrics sent from a host will have its tags applied. When fetching and applying tags to a particular host, you can refer to hosts by name (yourhost.example.com) or id (12345)."

NOTE: all methods, except retrieve_all(), operate on a per-host basis rather than on a per-tag basis. You cannot rename a tag or delete a tag from all hosts, through the DataDog API.

METHODS

retrieve_all()

Retrieve a mapping of tags to hosts.

        my $tag = $datadog->build('Tag');
        my $tag_host_list = $tag->retrieve_all();
        

Parameters: None

retrieve()

Return a list of tags for the specified host. NOTE: a 404 response typically indicates you specified an incorrect/unknown host name/id

        my $tag = $datadog->build('Tag');
        my $tag_list = $tag->retrieve( host => $host_name_or_id );
        

Parameters:

  • host

    Hostname/host id you want to retrieve the tags for.

update()

Update tags for specified host. NOTE: a 404 response typically indicates you specified an incorrect host name/id. WARNING: you must specify all tags that you want attached to this host, not simply new ones you want to add ( use add() for that, instead ).

        my $tag = $datadog->build('Tag');
        $tag->update(
                host => $host,  # name/ID of host to modify
                tags => $tag_list, # Updated full list of tags to apply to host
        );
        
        Example:
        $tag->update(
                host => 'my.example.com',
                tags => [ 'tag1', 'tag2', 'tag3:val' ],
        );
        

Parameters:

  • host

    Host name/id whose tags you want to modify.

  • tags

    List of tags to apply to host. This must be the full list you want applied, including any already applied.

add()

Add tags to specified host. NOTE: a 404 response typically indicates you specified an incorrect host name/id.

        my $tag = $datadog->build('Tag');
        $tag->add(
                host => $host,  # name/ID of host to modify
                tags => $tag_list, # Updated full list of tags to apply to host
        );
        
        Example:
        $tag->add(
                host => 'my.example.com',
                tags => [ 'tag3:val' ],
        );
        

Parameters:

  • host

    Host name/id whose tags you want to modify.

  • tags

    List of new tags to apply to existing tags on specified host.

delete()

Delete all tags from the specified host.

        my $tag = $datadog->build('Tag');
        $tag->delete( host => $host );
        

Parameters:

  • host

    Host name/id whose tags you want to delete.

INTERNAL FUNCTIONS

_error_checks()

Common error checking for adding/updating tags.