logstash-plugins / logstash-output-influxdb

Apache License 2.0
58 stars 77 forks source link

Support sprintf-formatting of column names in coerce_values #89

Open chengshiwen opened 4 years ago

chengshiwen commented 4 years ago

For the following configuration, the column name "%{field_key}" in coerce_values won't work, because column names in coerce_values do not support sprintf-formatting in version 5.0.5.

This pull request is supported.

input {
    stdin { }
}

filter {
    json {
        source => "message"
    }
    ruby {
        code => "event.set('epoch', (event.get('time') / 60.0).round * 60)"
    }
    mutate {
        add_field => {
            "field_key" => "%{instance}-%{metric}"
        }
    }
}

output {
    influxdb {
        host => "127.0.0.1"
        port => 8086
        db => "aiops_node"
        measurement => "node.%{host}"
        flush_size => 1000
        idle_flush_time => 5
        allow_time_override => true
        time_precision => "s"
        send_as_tags => []
        # exclude_fields => ["@timestamp", "@version", "sequence", "message", "type"]
        coerce_values => {
           "%{field_key}" => "float"
        }
        data_points => {
            "time" => "%{epoch}"
            "%{field_key}" => "%{value}"
        }
    }
}
cla-checker-service[bot] commented 4 years ago

💚 CLA has been signed