Skip to content

Instantly share code, notes, and snippets.

@spjmurray
Created June 7, 2016 12:40
Show Gist options
  • Save spjmurray/87d0374593acca9a51d598fe422b846c to your computer and use it in GitHub Desktop.
Save spjmurray/87d0374593acca9a51d598fe422b846c to your computer and use it in GitHub Desktop.
diff --git a/doc/6-object-types.md b/doc/6-object-types.md
index b0779e8..822270d 100644
--- a/doc/6-object-types.md
+++ b/doc/6-object-types.md
@@ -908,6 +908,45 @@ Configuration Attributes:
flush_interval | **Optional.** How long to buffer data points before transfering to InfluxDB. Defaults to `10s`
flush_threshold | **Optional.** How many data points to buffer before forcing a transfer to InfluxDB. Defaults
+### <a id="objecttype-influxdbwriter-instance-tags"></a> Instance Tagging
+
+Consider the following service check:
+
+ apply Service for (disk => attributes in host.vars.disks) {
+ import "generic-service"
+ check_command = "disk"
+ display_name = "Disk " + disk
+ vars.disk_partitions = disk
+ assign where host.vars.disks
+ }
+
+This is a typical pattern for checking individual disks, NICs, SSL certificates etc associated
+with a host. What would be useful is to have the data points tagged with the specific instance
+for that check. This would allow you to query time series data for a check on a host and for a
+specific instance e.g. /dev/sda. To do this quite simply add the instance to the service variables:
+
+ apply Service for (disk => attributes in host.vars.disks) {
+ ...
+ vars.instance = disk
+ ...
+ }
+
+Then modify your writer configuration to add this tag to your data points if the instance variable
+is associated with the service:
+
+ object InfluxdbWriter "influxdb" {
+ ...
+ service_template = {
+ measurement = "$service.check_command$"
+ tags = {
+ hostname = "$host.name$"
+ service = "$service.name$"
+ instance = "$service.vars.instance$"
+ }
+ }
+ ...
+ }
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment