Subversion Repositories Domoticz.mqtt

Rev

Blame | Last modification | View Log | Download

# Configuration file for telegraf
# Parse MQTT
# Store in influxdb v1

[[inputs.mqtt_consumer]]
  # use underscores
  alias = "dsmr"
  name_override = "dsmr"

  servers = ["tcp://mqtt:1883"]
  username = "username" # CHANGE
  password = "password" # CHANGE
  qos = 0
  persistent_session = false
  topics = [ "dsmr/el", "dsmr/gas" ]
  client_id = "telegraf-dsmr-d"

  data_format = "json_v2"
  [[inputs.mqtt_consumer.json_v2]]

    # A string that will become the new measurement name
    measurement_name = "dsmr"

    # A string with valid GJSON path syntax to a valid timestamp (single value)
    timestamp_path = "@this.timestamp"
    timestamp_format = "unix"

    [[inputs.mqtt_consumer.json_v2.object]]
      # A string with valid GJSON path syntax, can include array's and object's
      path = "@this"

      ### Configuration to define what JSON keys should be included and how (field/tag) ###
      # List of JSON keys (for a nested key, prepend the parent keys with underscores) to be a tag instead of a field,
      # when adding a JSON key in this list you don't have to define it in the included_keys list
      # database tag to determine which influxdb to be used
      tags = ["serial"]

      # List of JSON keys (for a nested key, prepend the parent keys with underscores) that shouldn't be included in result
      # Exclude the mqtt/json key "timestamp" from influxdb
      excluded_keys = ["timestamp"]

      # A map of JSON keys (for a nested key, prepend the parent keys with underscores) with a type (int,uint,float,string,bool)
      [inputs.mqtt_consumer.json_v2.object.fields]
        V1 = "uint"
        V2 = "uint"
        V3 = "uint"
        V1_sags = "uint"
        V2_sags = "uint"
        V3_sags = "uint"
        V1_swells = "uint"
        V2_swells = "uint"
        V3_swells = "uint"
        el_consumed = "uint"
        el_returned = "uint"
        p_consumed = "uint"
        p_generated = "uint"
#        P1_consumed = "uint"
#        P1_generated = "uint"
#        P2_consumed = "uint"
#        P2_generated = "uint"
#        P3_consumed = "uint"
#        P3_generated = "uint"
        long_power_failures = "uint"
        power_failures = "uint"
        timestamp = "uint"
        gas_consumed = "uint"

# Influx DB v1
[[outputs.influxdb]]
  urls = ["http://influxdb:8086"]
#  database = "dsmr" # required
  database = "dsmr"
  namepass = ["dsmr"]

  ## Retention policy to write to. Empty string writes to the default rp.
  retention_policy = ""
  ## Write consistency (clusters only), can be: "any", "one", "quorum", "all"
  write_consistency = "any"

  ## Write timeout (for the InfluxDB client), formatted as a string.
  ## If not provided, will default to 5s. 0s means no timeout (not recommended).
  timeout = "5s"


 # Prepare for transition to InfluxDB v2
 [[outputs.influxdb_v2]]
  ## The URLs of the InfluxDB cluster nodes.
  ##
  ## Multiple URLs can be specified for a single cluster, only ONE of the
  ## urls will be written to each interval.
  ##   ex: urls = ["https://us-west-2-1.aws.cloud2.influxdata.com"]
  urls = ["http://influxdb2:8086"]

  ## API token for authentication/write access to bucket.
  token = "my secrete token=="

  ## Organization is the name of the organization you wish to write to; must exist.
  ## Created at initialization of InfluxDB2 instance
  organization = "Home"

  ## Make sure that bucket does exist
  bucket = "dsmr"
  namepass = ["dsmr"]