Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for specific step size in CSV output #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

thorhs
Copy link

@thorhs thorhs commented Mar 22, 2018

Added flag --step, which is the step size in seconds. This will
generate a line every step seconds. Not specifying a step size,
or supplying a step size of 0 uses the previous step size
calculations.

Added flag --step, which is the step size in seconds.  This will
generate a line every step seconds.  Not specifying a step size,
or supplying a step size of 0 uses the previous step size
calculations.
This simplifies usage of the step feature by enabling users to specify
steps as 5m, or 24h.
@metalmatze
Copy link
Contributor

Does this result in the same steps when returning e.g. an hour by default?

Bumped testify up to v1.2.1 (latest) to get support for
duration units in asserts.
Steps are now tested to make sure errors are within 0.01 epsilon
since the steps function now returns a time.Duration (float64).

The steps function will now return an exact duration between steps
when we devide the input into 254 steps.
@thorhs
Copy link
Author

thorhs commented Apr 7, 2018

I updated the tests to be successful, sorry for not doing that initially.

As part of this PR, I switched the steps function to return a duration, in stead of integer seconds, as the prometheus API supports fractions in its steps.

If no --step flag is given, the previous behaviour is maintained, where we divide the duration into 254 steps. Since steps no longer uses whole seconds, but rather time.Duration, I switched the factor 4.2 with 254 steps which seems to be what the original intent was. The code feels cleaner when using time.Duration is used, since that is what is actually being worked on.

If --step is given, that actual value is used, bypassing the step calculation.

@ghost
Copy link

ghost commented Jun 28, 2021

I just tried to clone, build and test your repository. When using the --step or --s flag, it gives me the following error:

flag provided but not defined: -step

When runngin styx --help, the step flag is recognized correctly:

NAME:
   styx - Export metrics from prometheus

USAGE:
   styx [global options] command [command options] [arguments...]

VERSION:
   0.0.0

COMMANDS:
     gnuplot     Directly plot a graph with gnuplot
     matplotlib  Generate a file that uses matplotlib
     help, h     Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --step value, -s value      Step size in result data (default: 0s)
   --duration value, -d value  The duration to get timeseries from (default: 1h0m0s)
   --header                    Include a header into the csv file
   --prometheus value          (default: "http://localhost:9090")
   --help, -h                  show help
   --version, -v               print the version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants