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
Stream metrics to prometheus #172
base: master
Are you sure you want to change the base?
Conversation
load/loader.go
Outdated
Help: "TSBS load start/finish events.", | ||
}) | ||
eventTime.SetToCurrentTime() | ||
if err := push.New("http://pushgateway:9091", "tsbs_load"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we should keep this naming as pushgateway statically or have a way to allow people to configure it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO Configurable would be much better.
81aa0b8
to
2561bb8
Compare
d2730ea
to
d336e23
Compare
@@ -102,6 +113,15 @@ func GetBenchmarkRunner(c BenchmarkRunnerConfig) BenchmarkRunner { | |||
panic(fmt.Sprintf("could not initialize BenchmarkRunner: %v", err)) | |||
} | |||
} | |||
|
|||
if c.ReportingMetricsPort > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this type is uint64 and thus always positive or 0
, you could potentially drop this condition (but still need to sanitize it when variable is read from CLI flag). Doing so would reduce cyclomatic complexity by removing multiple if
s used with this variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love to drop the if condition.
(but still need to sanitize it when variable is read from CLI flag)
I'm not sure what you mean by sanitizing here. As we have this config that allows using json, yaml or params from CLI, we have the default value that is the real port. I used 0 in the tests to ignore the metrics.
I can move the rules to pushEventToPrometheus
but I'm not that familiar with go, so, if we have a way o get rid of the if, at all, I'm all for the change!
br := &CommonBenchmarkRunner{} | ||
b := &testBenchmark{} | ||
br.ReportingMetricsPort = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was comparing the port to check if it exists and then I need to set it to zero. Not sure what is the best place to set this default but I'll try to move it to the initializer and maybe it will not be needed if we just use the "full host" as a config.
Instead of collecting JSON or text output to analyze, let's start streaming all the metrics to promscale for further analysis.
Dashboard example
Annotations example
In the dashboard settings, go to annotations and add a new annotation based on promscale source:
You can also consider repeating the same all the events that are pushed to the gateway:
tsbs_run_start
,tsbs_run_finish
,tsbs_load_start
,tsbs_load_finish
.Configuration
I created the following structure for the promscale machine:
Create the
prometheus.yml
file in the folder:Now create the
docker-compose.yml
in the same directory:Then you can use
docker-compose up -d
to start running promscale with prometheus pushgateway too.Configure hosts
To make it easy to understand what machine do what, use
/etc/hosts
to create better names for the machines that are streaming the data. In our case, you can see our targets are already using some names:So, just go to
/etc/hosts
and create the following hosts:Now, you should also
ssh
bothtsbs
anddatabase
machines and install the node_exporter.How to test it:
start
./tsbs_load
and check the port 9101.In the bottom of the results you should see the new tsbs metrics:
If it's running queries the result should be a bit different: