Skip to content

CLI reference

Piotr Pawluk edited this page Jun 3, 2019 · 1 revision

CLI reference

Running app

statsender run

Starts the application in detached mode.


Flags

  • -c, --config

    Sets configuration directory location. statsender will parse all the .hcl files inside this directory to create the configuration.

    Default value: ./conf

    Example: statsender try --config=/path/to/your/conf/dir

  • -l, --log

    Sets log directory location.

    Default value: ./logs

    Example:statsender run --log=/path/to/your/log/dir

  • -v, --verbose

    Verbose output.

General configuration

statsender init

Generates default configuration files and examples of usage.


statsender try

Tests the application:

  • checks if the configuration can be parsed
  • checks if it is possible to establish connections to
    • databases
    • http endpoints.
  • displays stats that will be collected and when they would be be collected

Flags

  • -c, --config

    Sets configuration directory location. statsender will parse all the .hcl files inside this directory to create the configuration.

    Default value: ./conf

    Example: statsender try --config=/path/to/your/conf/dir

  • -v, --verbose

    Verbose output.

Datasources configuration

statsender datasource add <DSN> [<tags>]

Adds a new datasource. If not stated otherwise (with flag --file), it will be saved in ${config_dir}/_datasources.hcl


Arguments

  • DSN: [postgresql://]login:password@host[:port]/dbname[?param1=value1&...]
  • optional tags provided as flags --tag key1=value1 --tag key2=value2 ...

Examples:

statsender datasource add user:pass@localhost/testdb

statsender datasource add postgresql://user:pass@localhost:6432/testdb

statsender datasource add user:pass@10.0.3.13/proddb?sslmode=disable --tag env=prod --tag iteration=v1

Flags

  • -c, --config

    Sets configuration directory location. statsender will parse all the .hcl files inside this directory to create the configuration.

    Default value: ./conf

    Example: statsender try --config=/path/to/your/conf/dir

  • -f, --file

    Overrides the name of the configuration file to update.

    Default value: _datasources.hcl

    Example:statsender datasource add postgresql://user:pass@localhost:5432/testdb --file=yourfile.hcl

  • -v, --verbose

    Verbose output.

Senders configuration

statsender sender add <type> [<spec>]

Adds a new sender (or its target). If not stated otherwise (with flag --file), it will be saved in ${config_dir}/_senders.hcl


Arguments

  • type: console or http
  • spec:
    • if console, then none
    • if http, then full address of a target: http[s]://host[:port][/endpoint]

Examples:

statsender sender add console

statsender sender add http 10.0.1.1:8080/stats

statsender sender add http 10.0.1.1:8080/stats --retries 10 --delay 30

Flags

  • -r, --retries

    Only for http sender. Specifies how many times should the sender retry before giving up.

    Default value: 5

    Example: statsender sender add http 10.0.1.1:8080/stats --retries 10

  • -d, --delay

    Only for http sender. Specifies how long should the sender wait between retries (in seconds).

    Default value: 60

    Example: statsender sender add http 10.0.1.1:8080/stats --delay 30

  • -c, --config

    Sets configuration directory location. statsender will parse all the .hcl files inside this directory to create the configuration.

    Default value: ./conf

    Example: statsender try --config=/path/to/your/conf/dir

  • -f, --file

    Overrides the name of the configuration file to update.

    Default value: _senders.hcl

    Example:statsender sender add http 10.0.1.1:8080/stats --file=yourfile.hcl

  • -v, --verbose

    Verbose output.

Collectors configuration

statsender collector enable <type>

Enables a collector. If such collector does not exist, error is returned. If not stated otherwise (with flag --file), ${config_dir}/_collectors.hcl will be updated.


statsender collector disable <type>

Disables a collector. If such collector does not exist, error is returned. If not stated otherwise (with flag --file), ${config_dir}/_collectors.hcl will be updated.


statsender collector schedule <type> <cron>

Changes the cron schedule of a collector. If such collector does not exist, error is returned. If not stated otherwise (with flag --file), ${config_dir}/_collectors.hcl will be updated.


Arguments

  • type: full name of a collector (see reference(TODO))
  • cron: (quoted) string representing desired cron expression

Examples:

statsender collector enable cpu

statsender collector disable pg_stat_statements

statsender collector schedule pg_stat_user_indexes '0 0 * * * *'

statsender collector schedule pg_stat_user_indexes @hourly

Flags

  • -c, --config

    Sets configuration directory location. statsender will parse all the .hcl files inside this directory to create the configuration.

    Default value: ./conf

    Example: statsender try --config=/path/to/your/conf/dir

  • -f, --file

    Overrides the name of the configuration file to update.

    Default value: _collectors.hcl

    Example:statsender collector enable cpu --file=yourfile.hcl

  • -v, --verbose

    Verbose output.