Example: Configure Telegraf for Oracle Management Cloud Integration

The following example demonstrates how to integrate Telegraf with Oracle Management Cloud.

The generic metric collector's receiver in the cloud agent listens to requests sent to https://<host>:<port>/emd/receiver/gmc. Here, <port> is same port shown in the URL returned by running the omcli status agent command on the cloud agent host. On the Telegraf side, the same information is provided in its configuration file, as shown in the following example.

# Global tags can be specified here in key="value" format.
[global_tags]
  collector = "telegraf"
 
[[outputs.http]]
   url = "https://127.0.0.1:1899/emd/receiver/gmc"
   method = "POST"
   insecure_skip_verify = true
   data_format = "json"

The POST method is used to send and receive metrics. Also, the above configuration sets a global tag called collector to the value telegraf. This setting is essential and is used by cloud agent to recognize metrics sent by Telegraf.

Note:

If Telegraf is remotely located relative to the cloud agent host, specify the cloud agent host name instead of the loop-back address of 127.0.0.1. More on this configuration is covered in Receive Metrics from a Remote Telegraf Collector.

Metrics sent by Telegraf are posted against entities in Oracle Management Cloud whose names are derived using the value of the host tag set in Telegraf's payload sent to cloud agent. This value is usually the short host name by default. If multiple hosts can exist with the same short host name (in different domains) within your tenancy, you also need to set the hostname tag to the host's FQDN to disambiguate the entity names that will be created in Oracle Management Cloud.

[agent] hostname="myhost.myco.com"

Incorporate HTTP Basic Authentication Scheme (Optional)

To protect the receiver URI, a new credential with username and password can be added to the cloud agent using the omcli add_credentials command:

omcli add_credentials agent -credential_file http_receiver_auth.json

Example content for the http_receiver_auth.json is shown below.

[
  { "entity":"Lama.mycompany.com:1899",
    "name":"omc-receiver-cred",
    "type":"HttpReceiver-Auth",
    "globalName":"HttpReceiver.basic",
    "description":"Internal authorization for the HTTP receiver",
    "properties":[ { "name":"username", "value":"CLEAR[scott]" },
                   { "name":"password", "value":"CLEAR[tiger]" } ]
 }
]

Here, the cloud agent entity is specified in <type>.<name> format (using a period (.) as a separator) where the <name> includes the agent's listening port. The properties username and password are set to scott and tiger respectively. The sender will be required to authenticate with these credentials.

Share this secret with Telegraf by adding the username and password parameters to the outputs.http section in the telegraf.conf file as shown below.

[[outputs.http]]
   url = "https://<Cloud Agent's Host Name>:<Cloud Agent's HTTP SSL Port>/emd/receiver/gmc"
   method = "POST"
   insecure_skip_verify = true
   data_format = "json"
   username = "scott"
   password = "tiger"

In order for a cloud agent to be able to monitor Telegraf, Telegraf must be configured to run as a service.