# collectd configuration for storing metrics into CrateDB.
# https://cratedb.com/docs/guide/integrate/collectd/

# https://collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresql

LoadPlugin postgresql

<Plugin postgresql>
        <Writer sqlstore>
                Statement "INSERT INTO doc.collectd_data (p_time, p_host, p_plugin, p_plugin_instance, p_type, p_type_instance, p_value_names, p_type_names, p_values) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9);"
                StoreRates true
        </Writer>
        <Database cratedb>
                Writer sqlstore
                # Commit every 30 seconds (adjust based on write volume)
                CommitInterval 30
                Host cratedb
                User crate
                Password crate
        </Database>
</Plugin>
