Skip to content

write_stackdriver plugin

Plugin name write_stackdriver
Type write
Callbacks config, flush, init, write
Status in development
Since 5.9
Copyright 2018 Florian Forster
License MIT License
Configuration collectd.conf(5)

The Write Stackdriver plugin stores metrics in Google Stackdriver.

Synopsis

 LoadPlugin "write_stackdriver"
 <Plugin "write_stackdriver">
   CredentialFile "/path/to/gcp-project-id-12345.json"
 </Plugin>

Dependencies

  • libyajl, versionĀ 2
  • libcurl
  • OpenSSL

See also

Configuration

Configuration options · from collectd.conf(5)

See this section in the full configuration reference

The write_stackdriver plugin writes metrics to the Google Stackdriver Monitoring service.

This plugin supports two authentication methods: When configured, credentials are read from the JSON credentials file specified with CredentialFile. Alternatively, when running on Google Compute Engine (GCE), an OAuth token is retrieved from the metadata server and used to authenticate to GCM.

Synopsis:

<Plugin write_stackdriver>
  CredentialFile "/path/to/service_account.json"
  <Resource "global">
    Label "project_id" "monitored_project"
  </Resource>
</Plugin>
CredentialFile file

Path to a JSON credentials file holding the credentials for a GCP service account.

If CredentialFile is not specified, the plugin uses Application Default Credentials. That means which credentials are used depends on the environment:

  • The environment variable GOOGLE_APPLICATION_CREDENTIALS is checked. If this variable is specified it should point to a JSON file that defines the credentials.

  • The path ${HOME}/.config/gcloud/application_default_credentials.json is checked. This where credentials used by the gcloud command line utility are stored. You can use gcloud auth application-default login to create these credentials.

    Please note that these credentials are often of your personal account, not a service account, and are therefore unfit to be used in a production environment.

  • When running on GCE, the built-in service account associated with the virtual machine instance is used. See also the Email option below.

Project Project

The Project ID or the Project Number of the Stackdriver Account. The Project ID is a string identifying the GCP project, which you can chose freely when creating a new project. The Project Number is a 12-digit decimal number. You can look up both on the Developer Console.

This setting is optional. If not set, the project ID is read from the credentials file or determined from the GCE's metadata service.

Email Email (GCE only)

Choses the GCE Service Account used for authentication.

Each GCE instance has a default Service Account but may also be associated with additional Service Accounts. This is often used to restrict the permissions of services running on the GCE instance to the required minimum. The write_stackdriver plugin requires the https://www.googleapis.com/auth/monitoring scope. When multiple Service Accounts are available, this option selects which one is used by write_stackdriver plugin.

Resource ResourceType

Configures the Monitored Resource to use when storing metrics. More information on Monitored Resources and Monitored Resource Types are available at https://cloud.google.com/monitoring/api/resources.

This block takes one string argument, the ResourceType. Inside the block are one or more Label options which configure the resource labels.

This block is optional. The default value depends on the runtime environment: on GCE, the gce_instance resource type is used, otherwise the global resource type ist used:

  • On GCE, defaults to the equivalent of this config:

    <Resource "gce_instance">
      Label "project_id" "<project_id>"
      Label "instance_id" "<instance_id>"
      Label "zone" "<zone>"
    </Resource>
    

    The values for project_id, instance_id and zone are read from the GCE metadata service.

  • Elsewhere, i.e. not on GCE, defaults to the equivalent of this config:

    <Resource "global">
      Label "project_id" "<Project>"
    </Resource>
    

    Where Project refers to the value of the Project option or the project ID inferred from the CredentialFile.

Url Url
URL of the Stackdriver Monitoring API. Defaults to https://monitoring.googleapis.com/v3.