From b0b911e4f4446a62a3f5478aff98a4720bb4c959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Nordstro=CC=88m?= Date: Mon, 19 Mar 2018 09:18:24 +0100 Subject: [PATCH] Make command-line arguments namespaced and consistent This changes the command-line args to use a dot-separated namespace prefix to be consistent with common practices in other projects and dependencies. --- main.go | 2 +- postgresql/client.go | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/main.go b/main.go index 6464321..4698e0f 100644 --- a/main.go +++ b/main.go @@ -103,7 +103,7 @@ func parseFlags() *config { pgprometheus.ParseFlags(&cfg.pgPrometheusConfig) - flag.DurationVar(&cfg.remoteTimeout, "send-timeout", 30*time.Second, "The timeout to use when sending samples to the remote storage.") + flag.DurationVar(&cfg.remoteTimeout, "adapter.send-timeout", 30*time.Second, "The timeout to use when sending samples to the remote storage.") flag.StringVar(&cfg.listenAddr, "web.listen-address", ":9201", "Address to listen on for web endpoints.") flag.StringVar(&cfg.telemetryPath, "web.telemetry-path", "/metrics", "Address to listen on for web endpoints.") flag.StringVar(&cfg.logLevel, "log.level", "debug", "The log level to use [ \"error\", \"warn\", \"info\", \"debug\" ].") diff --git a/postgresql/client.go b/postgresql/client.go index 76a6314..f355409 100644 --- a/postgresql/client.go +++ b/postgresql/client.go @@ -41,21 +41,21 @@ type Config struct { // ParseFlags parses the configuration flags specific to PostgreSQL and TimescaleDB func ParseFlags(cfg *Config) *Config { - flag.StringVar(&cfg.host, "pg-host", "localhost", "The PostgreSQL host") - flag.IntVar(&cfg.port, "pg-port", 5432, "The PostgreSQL port") - flag.StringVar(&cfg.user, "pg-user", "postgres", "The PostgreSQL user") - flag.StringVar(&cfg.password, "pg-password", "", "The PostgreSQL password") - flag.StringVar(&cfg.database, "pg-database", "postgres", "The PostgreSQL database") - flag.StringVar(&cfg.schema, "pg-schema", "", "The PostgreSQL schema") - flag.StringVar(&cfg.sslMode, "pg-ssl-mode", "disable", "The PostgreSQL connection ssl mode") - flag.StringVar(&cfg.table, "pg-table", "metrics", "The PostgreSQL table") - flag.StringVar(&cfg.copyTable, "pg-copy-table", "metrics_copy", "The PostgreSQL table") - flag.IntVar(&cfg.maxOpenConns, "pg-max-open-conns", 50, "The max number of open connections to the database") - flag.IntVar(&cfg.maxIdleConns, "pg-max-idle-conns", 10, "The max number of idle connections to the database") - flag.BoolVar(&cfg.pgPrometheusNormalize, "pg-prometheus-normalized-schema", true, "Insert metric samples into normalized schema") - flag.BoolVar(&cfg.pgPrometheusLogSamples, "pg-prometheus-log-samples", false, "Log raw samples to stdout") - flag.DurationVar(&cfg.pgPrometheusChunkInterval, "pg-prometheus-chunk-interval", time.Hour*12, "The size of a time-partition chunk in TimescaleDB") - flag.BoolVar(&cfg.useTimescaleDb, "pg-use-timescaledb", true, "Use timescaleDB") + flag.StringVar(&cfg.host, "pg.host", "localhost", "The PostgreSQL host") + flag.IntVar(&cfg.port, "pg.port", 5432, "The PostgreSQL port") + flag.StringVar(&cfg.user, "pg.user", "postgres", "The PostgreSQL user") + flag.StringVar(&cfg.password, "pg.password", "", "The PostgreSQL password") + flag.StringVar(&cfg.database, "pg.database", "postgres", "The PostgreSQL database") + flag.StringVar(&cfg.schema, "pg.schema", "", "The PostgreSQL schema") + flag.StringVar(&cfg.sslMode, "pg.ssl-mode", "disable", "The PostgreSQL connection ssl mode") + flag.StringVar(&cfg.table, "pg.table", "metrics", "The PostgreSQL table") + flag.StringVar(&cfg.copyTable, "pg.copy-table", "metrics_copy", "The PostgreSQL table") + flag.IntVar(&cfg.maxOpenConns, "pg.max-open-conns", 50, "The max number of open connections to the database") + flag.IntVar(&cfg.maxIdleConns, "pg.max-idle-conns", 10, "The max number of idle connections to the database") + flag.BoolVar(&cfg.pgPrometheusNormalize, "pg.prometheus-normalized-schema", true, "Insert metric samples into normalized schema") + flag.BoolVar(&cfg.pgPrometheusLogSamples, "pg.prometheus-log-samples", false, "Log raw samples to stdout") + flag.DurationVar(&cfg.pgPrometheusChunkInterval, "pg.prometheus-chunk-interval", time.Hour*12, "The size of a time-partition chunk in TimescaleDB") + flag.BoolVar(&cfg.useTimescaleDb, "pg.use-timescaledb", true, "Use timescaleDB") return cfg }