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

basic prototype for prometheus logging #146

Closed
wants to merge 1 commit into from
Closed

Conversation

briancoutinho
Copy link
Contributor

@briancoutinho briancoutinho commented Jun 10, 2023

Prometheus support

#148
Enable logging to prometheus- this will be used in environments with their prometheus logging set up already.
We leverage the library https://github.com/jupp0r/prometheus-cpp/ for this work.

Parts

  1. Add a Metrics list registry in the code.
  2. Use Prometheus-cpp to set up an HTTP endpoint for prometheus.

Output

Ran on my laptop using a docker container.

How to Run

Please install Docker desktop.

  1. Download this docker file in a directory https://gist.github.com/briancoutinho/d90e1c5d3fca59274fcd14f8863d6409
  2. Build using docker build . -t prometheus:v1
  3. Run docker container forwarding port and mounting dynolog open source repo
    docker run -p 9090:9090 -it -v ~/Work/dynolog_oss/dynolog:/workspace/dynolog prometheus:v1 /bin/bash
  4. Build dynolog ./scripts/build.sh

To get the logging setup add the following in prometheus.yml

  - job_name: "dynolog"
    static_configs:
      - targets: ["localhost:8080"]

Then run prometheus and dynolog.

cd /workspace/prometheus/prometheus-2.44.0.linux-amd64;
./prometheus --config.file prometheus.yml &
cd -
./build/bin/dynolog -kernel_monitor_reporting_interval_s 10 -use_JSON -use_prometheus &

Open https://localhost:9090/

Screenshot 2023-06-09 at 4 26 52 PM
Screenshot 2023-06-09 at 4 26 59 PM

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 10, 2023
@@ -0,0 +1,28 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are Metrics specific to Prometheus? If so, should the naming reflect that?

@@ -57,6 +64,11 @@ DEFINE_bool(enable_perf_monitor, false, "Enable heartbeat perf monitoring.");

std::unique_ptr<Logger> getLogger(const std::string& scribe_category = "") {
std::vector<std::unique_ptr<Logger>> loggers;
#ifdef USE_PROMETHEUS
if (FLAGS_use_prometheus) {
loggers.push_back(std::make_unique<PrometheusLogger>());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Have the Prometheus server port/ip binding parameterized

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes added that :)

@briancoutinho briancoutinho marked this pull request as ready for review June 14, 2023 01:01
@facebook-github-bot
Copy link
Contributor

@briancoutinho has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

briancoutinho added a commit that referenced this pull request Jun 15, 2023
Summary:
# Prometheus support

Enable logging to prometheus- this will be used in environments with their prometheus logging set up already.
We leverage the library https://github.com/jupp0r/prometheus-cpp/ for this work.

## Parts
1. Add a Metrics list registry in the code.
2. Use Prometheus-cpp to set up an HTTP endpoint for prometheus.

## Output
Ran on my laptop using a docker container.

### How to Run
Please install Docker desktop.
1. Download this docker file in a directory https://gist.github.com/briancoutinho/d90e1c5d3fca59274fcd14f8863d6409
2. Build using `docker build . -t prometheus:v1`
3. Run docker container forwarding port and mounting dynolog open source repo
   `docker run -p 9090:9090 -it -v ~/Work/dynolog_oss/dynolog:/workspace/dynolog prometheus:v1 /bin/bash`
5. Build dynolog `./scripts/build.sh`

To get the logging setup add the following in prometheus.yml
```
  - job_name: "dynolog"
    static_configs:
      - targets: ["localhost:8080"]
```
Then run prometheus and dynolog.
```
cd /workspace/prometheus/prometheus-2.44.0.linux-amd64;
./prometheus --config.file prometheus.yml &
cd -
./build/bin/dynolog -kernel_monitor_reporting_interval_s 10 -use_JSON -use_prometheus &
```
Open [https://localhost:9090](http://localhost:9090/metrics)/

![Screenshot 2023-06-09 at 4 26 52 PM](https://github.com/facebookincubator/dynolog/assets/6922212/4015bb3e-9751-4167-88d1-7865b1efd8b6)
![Screenshot 2023-06-09 at 4 26 59 PM](https://github.com/facebookincubator/dynolog/assets/6922212/74186161-c2c1-4649-b560-8fbb58fc7664)

Pull Request resolved: #146

Differential Revision: D46710501

Pulled By: briancoutinho

fbshipit-source-id: 77083bfe56e76780d13e4e90395261012ef4bf28
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46710501

Summary:
# Prometheus support

Enable logging to prometheus- this will be used in environments with their prometheus logging set up already.
We leverage the library https://github.com/jupp0r/prometheus-cpp/ for this work.

## Parts
1. Add a Metrics list registry in the code.
2. Use Prometheus-cpp to set up an HTTP endpoint for prometheus.

## Output
Ran on my laptop using a docker container.

### How to Run
Please install Docker desktop.
1. Download this docker file in a directory https://gist.github.com/briancoutinho/d90e1c5d3fca59274fcd14f8863d6409
2. Build using `docker build . -t prometheus:v1`
3. Run docker container forwarding port and mounting dynolog open source repo
   `docker run -p 9090:9090 -it -v ~/Work/dynolog_oss/dynolog:/workspace/dynolog prometheus:v1 /bin/bash`
5. Build dynolog `./scripts/build.sh`

To get the logging setup add the following in prometheus.yml
```
  - job_name: "dynolog"
    static_configs:
      - targets: ["localhost:8080"]
```
Then run prometheus and dynolog.
```
cd /workspace/prometheus/prometheus-2.44.0.linux-amd64;
./prometheus --config.file prometheus.yml &
cd -
./build/bin/dynolog -kernel_monitor_reporting_interval_s 10 -use_JSON -use_prometheus &
```
Open [https://localhost:9090](http://localhost:9090/metrics)/

![Screenshot 2023-06-09 at 4 26 52 PM](https://github.com/facebookincubator/dynolog/assets/6922212/4015bb3e-9751-4167-88d1-7865b1efd8b6)
![Screenshot 2023-06-09 at 4 26 59 PM](https://github.com/facebookincubator/dynolog/assets/6922212/74186161-c2c1-4649-b560-8fbb58fc7664)

Pull Request resolved: #146

Reviewed By: jj10306

Differential Revision: D46710501

Pulled By: briancoutinho

fbshipit-source-id: fd5f74326446b7daa4d9d93a7891cb6ac89f85a1
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46710501

@facebook-github-bot
Copy link
Contributor

@briancoutinho merged this pull request in 1fa5af7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants