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

Docs metrics configuration #1850

Merged
merged 6 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/developers/images/img_grafana.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions docs/developers/metrics-configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
## Metrics configuration and how to import metrics of [Prebid server](https://docs.prebid.org/prebid-server/versions/pbs-versions-go.html) to [Grafana](https://grafana.com/) through [Prometheus](https://prometheus.io/) stack.

#### These are the parameters that are capable for metrics collection

- PBS_METRICS_PROMETHEUS_PORT=9100 - default is 0.

If PBS_METRICS_PROMETHEUS_PORT is null, your [Prebid server](https://docs.prebid.org/prebid-server/versions/pbs-versions-go.html) won't collect any metrics.

- PBS_METRICS_PROMETHEUS_NAMESPACE=prebid - default is empty.

PBS_METRICS_PROMETHEUS_NAMESPACE - for your unique metrics
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe elaborate a bit indicating that this is the primary prefix added to your metrics to ensure uniqueness within your cluster?


- PBS_METRICS_PROMETHEUS_SUBSYSTEM=server - default is empty.

PBS_METRICS_PROMETHEUS_NAMESPACE - for your deep unique metrics
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be PBS_METRICS_PROMETHEUS_SUBSYSTEM?

Similar to my above comment, perhaps clarify that this is a secondary prefix added to metrics to ensure uniqueness?


- PBS_METRICS_DISABLED_METRICS_ADAPTER_CONNECTIONS_METRICS=false - default is true.

If PBS_METRICS_DISABLED_METRICS_ADAPTER_CONNECTIONS_METRICS is true your [Prebid server](https://docs.prebid.org/prebid-server/versions/pbs-versions-go.html) won't collect any adapter metrics
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the description here needs to be altered. If this flag is set to true you won't get any bidder http connection adapter metrics (e.g. number of new vs reused connections) but you'll still get other adapter metrics.


#### If you're going to get metrics though [Prometheus](https://prometheus.io/) and [Prometheus](https://prometheus.io/) stack has been already installed, you have several options, please chose one:

- change environments into code (bad way).

- create pbs.yaml if it hasn't been already created (It works, but not flexible).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, what problem did you experience with this approach that makes it inflexible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TimofeySemenenko thank you for taking the initiative on documenting Prometheus integration. There's just a few more comments and then I'd like to merge this in for everyone to benefit.

@SyntaxNode I'm sorry my being late caused such confusion.. I went on vacation and couldn't respond. I'm going to fix it according to the code review. I'll do my best.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a problem. It's looking great so far.


- input the parameters into global environments (Highly recommend you to use this way also it's reliable).

#### Finally, when you fill in your credentials of metrics, please, run:

```bash
./validate.sh
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running ./validate.sh (all unit tests) doesn't test the correctness of production Prometheus configuration.
In this context it feels like this will be an indicator if setup is correct. Can you please specify this explicitly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VeronikaSolovei9
Yes, I've just mistaken.
There should be the commands that help to build and run prebid-server locally

  • go build .
  • ./prebid-server
    I've already fixed it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, looks good!

#### Make sure that an application returns any metrics - `http://localhost:9100/metrics`, if not, please check your names of environment and recompile again.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: also available at http://localhost:9100 as Prometheus runs within separate service, not endpoint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed it.


#### Add your host and port into prometheus.yml file on the instance of your [Prometheus](https://prometheus.io/).

```yaml
global:
scrape_interval: 15s
evaluation_interval: 15s

external_labels:
monitor: 'docker-host-alpha'

rule_files:
- "alert.rules"

scrape_configs:
- job_name: 'prometheus'
scrape_interval: 10s
static_configs:
- targets: [ 'prometheus-host:9090']

- job_name: 'prebidserver-metrics'
scrape_interval: 10s
static_configs:
- targets: ['prebidserver-host:9100' ]
alerting:
alertmanagers:
- scheme: http
static_configs:
- targets:
- 'localhost:9093'
```

#### Import data source as [Prometheus](https://prometheus.io/) into [Grafana](https://grafana.com/)

Just fill in host and port of [Prometheus](https://prometheus.io/)

![img_grafana.png](images/img_grafana.png)

#### In that case [Prebid server](https://docs.prebid.org/prebid-server/versions/pbs-versions-go.html) uses [package](https://github.com/prometheus/client_golang) in our case it works as [Node exporter](https://github.com/prometheus/node_exporter). Therefore, here is described only how to connect [Prebid server](https://docs.prebid.org/prebid-server/versions/pbs-versions-go.html) connection with [Prometheus](https://prometheus.io/). Also, if you are interested in [Prometheus](https://prometheus.io/) and want to dig deep, follow [docs](https://prometheus.io/docs/introduction/overview/).