AppMetrics / InfluxDB

App Metrics Extensions for InfluxDB reporting
https://www.app-metrics.io/reporting/reporters/influx-data/
Apache License 2.0
17 stars 13 forks source link

Please provide a way to create default retention policy for database in case of creation a new database #38

Closed IharYakimush closed 6 years ago

IharYakimush commented 6 years ago

I am using nuget package App.Metrics.Reporting.InfluxDB 2.0.0

It has an option to create database if it not exists, however it can't create retention policy for it.

Code sample:

metrics.Report.ToInfluxDb(options =>
            {
                options.InfluxDb.CreateDataBaseIfNotExists = true;
                options.FlushInterval = TimeSpan.FromSeconds(5);
                options.InfluxDb.BaseUri = Consts.InfluxDb.Uri;
                options.InfluxDb.Database = Consts.InfluxDb.MetricsDbName; //db0
                options.InfluxDb.RetensionPolicy = Consts.InfluxDb.RetentionPolicy; //15m
            });

Influx DB logs:

[httpd] 172.23.0.12 - - [26/Jul/2018:09:05:53 +0000] "POST /write?db=db0&rp=15m HTTP/1.1" 500 44 "-" "-" 199085e8-90b3-11e8-800d-000000000000 77
ts=2018-07-26T09:05:53.724864Z lvl=error msg="[500] - \"retention policy not found: 15m\"" log_id=09XRzUdl000 service=httpd

So I assume that options.InfluxDb.RetensionPolicy can be used to specify existing policy on existing database only.

Please provide a way to create default retention policy for database in case of creation a new database.

alhardy commented 6 years ago

The create database option really only exists as a convenience thing for development, happy to put this on the backlog, not an urgent ticket for me though but more than happy to take a PR?