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

v0.1 in rust #6

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open

v0.1 in rust #6

wants to merge 35 commits into from

Conversation

escanda
Copy link
Collaborator

@escanda escanda commented Dec 6, 2022

I open this PR for review. In a Fedora 37 Workstation shell you can do from the project's root: sudo dnf -y install podman-compose && podman-compose up. We have some work to do yet but I open the issue in case you find something shaky we might need to change.

@escanda escanda requested a review from sbates130272 December 6, 2022 23:28
@escanda escanda self-assigned this Dec 6, 2022
@escanda escanda mentioned this pull request Dec 6, 2022
Copy link
Owner

@sbates130272 sbates130272 left a comment

Choose a reason for hiding this comment

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

@escanda looks like we have the beginnings of a v0.1. I would like two things.

  1. Address all the comments in my review.
  2. Move to an Ubuntu based approach. Change any Fedora based comments to Ubuntu based ones.
  3. Let's reduce this branch to 3 commits. One for the main code, one for the docker files and docker-compose. And one for documentation (update the README).

.gitignore Outdated Show resolved Hide resolved
Cargo.lock Outdated Show resolved Hide resolved
Cargo.toml Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
build.rs Outdated Show resolved Hide resolved
docker-compose.yml Outdated Show resolved Hide resolved
docker-compose.yml Outdated Show resolved Hide resolved
fedora-with-blktrace/Dockerfile Outdated Show resolved Hide resolved
prometheus.yml Outdated Show resolved Hide resolved
prometheus.yml Outdated Show resolved Hide resolved
@escanda escanda mentioned this pull request Dec 8, 2022
@escanda escanda force-pushed the gcifuentes/dev/rust branch from 8d7cc97 to 17e6e84 Compare December 12, 2022 23:01
@escanda escanda force-pushed the gcifuentes/dev/rust branch from 17e6e84 to 5b2fd44 Compare December 13, 2022 00:09
@escanda escanda requested a review from sbates130272 December 13, 2022 00:19
@escanda escanda force-pushed the gcifuentes/dev/rust branch from 6319aa9 to e92f637 Compare December 13, 2022 00:35
Copy link
Owner

@sbates130272 sbates130272 left a comment

Choose a reason for hiding this comment

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

@escanda a few more updates. Getting closer. I should have some time tomorrow to meet.

.github/workflows/rust.yml Outdated Show resolved Hide resolved
.github/workflows/rust.yml Outdated Show resolved Hide resolved
.github/workflows/rust.yml Outdated Show resolved Hide resolved
Dockerfile Outdated
@@ -0,0 +1,13 @@
FROM rust:1.65.0
RUN apt-get update && \
apt-get install -y g++ cmake llvm-dev clang libclang-dev
Copy link
Owner

Choose a reason for hiding this comment

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

NIT: @escanda I prefer one package per line. Much cleaner to update that way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure if best, we may create too many intermediate docker images if we do it by package, each upper case command creates an intermediate image, shall we?

Copy link
Owner

Choose a reason for hiding this comment

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

@escanda i mean one run statement but put each package on its own line.

@@ -1 +1,5 @@
*~
/target
Copy link
Owner

Choose a reason for hiding this comment

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

The commit message for this is way to short. Use something like this:

iowatcher-ng: Initial rust-based exporter.

Commit the initial files associated with a rust-based Prometheus exporter for iowatcher-ng. This includes the cargo manifesto and the source code for an initial version.

COPY . .
RUN cargo install --path .

FROM ubuntu:22.04
Copy link
Owner

Choose a reason for hiding this comment

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

Do we really need both FROM? Can we not do this from Ubuntu 22.04?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Rust image to build is based in debian so no dynamic libs issues transferring then the image to ubuntu. It even helps the build be smaller. Beside rust execs are static by default. What shall we do? :)


volumes:
prometheus_data: {}
grafana-data: {}
Copy link
Owner

Choose a reason for hiding this comment

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

Why is one a hyphen and one an underscore. Be consistent please.

prometheus.yml Outdated
static_configs:
- targets: ["node-exporter:9100"]

- job_name: "blkio-exporter"
Copy link
Owner

Choose a reason for hiding this comment

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

Why use blkio? Use iowatcher-ng-exporter please.

@@ -0,0 +1,13 @@
FROM rust:1.65.0
Copy link
Owner

Choose a reason for hiding this comment

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

Again the commit message is way to short. Use something like:

docker: Add Dockerfile and docker-compose for project.

The iowatcher-ng exporter runs best inside a docker container so we add a Dockerfile and docker-compose to assist in deployment.

docs/index.adoc Outdated
@@ -0,0 +1,16 @@
= iowatcher-ng documentation
Copy link
Owner

Choose a reason for hiding this comment

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

For commit message this is not a workflow so do something like

docs: Add documentation

etc.

But to be honest I prefer markdown as it does not need a compile step so let's switch to that.

@sbates130272
Copy link
Owner

@escanda node that the build step seems to be failing in the workflow?

@sbates130272
Copy link
Owner

@escanda I think you also want to add a .dockerignore file to ignore the large target folder which may exist. It is not needed in the docker context.

@sbates130272
Copy link
Owner

batesste@bunbeg:~/Projects/iowatcher-ng$ docker ps
CONTAINER ID   IMAGE                         COMMAND                  CREATED              STATUS         PORTS                                                           NAMES
1fcab7ea4d0e   prom/prometheus:v2.40.5       "/bin/prometheus --c…"   About a minute ago   Up 6 seconds   0.0.0.0:9090->9090/tcp, :::9090->9090/tcp                       prometheus
011a105a9a78   prom/node-exporter:v1.5.0     "/bin/node_exporter …"   About a minute ago   Up 6 seconds   0.0.0.0:9100->9100/tcp, :::9100->9100/tcp                       node-exporter
5cc4d8fe0352   grafana/grafana:7.5.7         "/run.sh"                2 minutes ago        Up 6 seconds   0.0.0.0:3000->3000/tcp, :::3000->3000/tcp                       iowatcher-ng-grafana-1
18f986a584e3   iowatcherng-exporter:v0.1.0   "bash -c 'nc -l -p 9…"   2 minutes ago        Up 6 seconds   0.0.0.0:9000-9001->9000-9001/tcp, :::9000-9001->9000-9001/tcp   iowatcher-ng-blkio-exporter-1

Can we make the container names consistent?

@sbates130272
Copy link
Owner

Please use port 9975 for iowatcher-ng-exporter as I have reserved this port for this exporter. See here for details.

@sbates130272
Copy link
Owner

So things seem to be sort of working in the docker-compose. I can see the Prometheus server and the targets all seem to be up. I can see node-exporter on 9100 but I cannot see the iowatcher metrics on 9000 or 9001?

@sbates130272
Copy link
Owner

Oh and I see the iowatcher contain died:

iowatcher-ng-grafana-1         | t=2022-12-14T14:01:10+0000 lvl=eror msg="Data proxy error" logger=data-proxy-log userId=1 orgId=1 uname=admin path=/api/datasources/proxy/4/api/v1/query remote_addr=172.18.0.1 referer="http://localhost:3000/datasources/edit/4/?utm_source=grafana_gettingstarted" error="http: proxy error: dial tcp 127.0.0.1:9090: connect: connection refused"
iowatcher-ng-grafana-1         | t=2022-12-14T14:01:10+0000 lvl=eror msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/datasources/proxy/4/api/v1/query status=502 remote_addr=172.18.0.1 time_ms=4 size=0 referer="http://localhost:3000/datasources/edit/4/?utm_source=grafana_gettingstarted"
iowatcher-ng-grafana-1         | t=2022-12-14T14:01:19+0000 lvl=eror msg="Data proxy error" logger=data-proxy-log userId=1 orgId=1 uname=admin path=/api/datasources/proxy/4/api/v1/query remote_addr=172.18.0.1 referer="http://localhost:3000/datasources/edit/4/?utm_source=grafana_gettingstarted" error="http: proxy error: dial tcp 127.0.0.1:9090: connect: connection refused"
iowatcher-ng-grafana-1         | t=2022-12-14T14:01:19+0000 lvl=eror msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/datasources/proxy/4/api/v1/query status=502 remote_addr=172.18.0.1 time_ms=3 size=0 referer="http://localhost:3000/datasources/edit/4/?utm_source=grafana_gettingstarted"
iowatcher-ng-grafana-1         | t=2022-12-14T14:01:33+0000 lvl=eror msg="Data proxy error" logger=data-proxy-log userId=1 orgId=1 uname=admin path=/api/datasources/proxy/4/api/v1/query remote_addr=172.18.0.1 referer="http://localhost:3000/datasources/edit/4/?utm_source=grafana_gettingstarted" error="http: proxy error: dial tcp 127.0.0.1:9090: connect: connection refused"
iowatcher-ng-grafana-1         | t=2022-12-14T14:01:33+0000 lvl=eror msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/datasources/proxy/4/api/v1/query status=502 remote_addr=172.18.0.1 time_ms=1 size=0 referer="http://localhost:3000/datasources/edit/4/?utm_source=grafana_gettingstarted"
iowatcher-ng-grafana-1         | t=2022-12-14T14:01:35+0000 lvl=eror msg="Data proxy error" logger=data-proxy-log userId=1 orgId=1 uname=admin path=/api/datasources/proxy/4/api/v1/query remote_addr=172.18.0.1 referer="http://localhost:3000/datasources/edit/4/?utm_source=grafana_gettingstarted" error="http: proxy error: dial tcp 127.0.0.1:9090: connect: connection refused"
iowatcher-ng-grafana-1         | t=2022-12-14T14:01:35+0000 lvl=eror msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/datasources/proxy/4/api/v1/query status=502 remote_addr=172.18.0.1 time_ms=0 size=0 referer="http://localhost:3000/datasources/edit/4/?utm_source=grafana_gettingstarted"
iowatcher-ng-grafana-1         | t=2022-12-14T14:01:47+0000 lvl=eror msg="Data proxy error" logger=data-proxy-log userId=1 orgId=1 uname=admin path=/api/datasources/proxy/4/api/v1/query remote_addr=172.18.0.1 referer="http://localhost:3000/datasources/edit/4/?utm_source=grafana_gettingstarted" error="http: proxy error: dial tcp 127.0.0.1:9090: connect: connection refused"
iowatcher-ng-grafana-1         | t=2022-12-14T14:01:47+0000 lvl=eror msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/datasources/proxy/4/api/v1/query status=502 remote_addr=172.18.0.1 time_ms=1 size=0 referer="http://localhost:3000/datasources/edit/4/?utm_source=grafana_gettingstarted"
iowatcher-ng-blkio-exporter-1  | Bad pkt magic
iowatcher-ng-blkio-exporter-1 exited with code 0

@sbates130272
Copy link
Owner

When running docker-compose up

iowatcherng_exporter  | bash: line 1: iowatcherng-exporter: command not found

@gitguardian
Copy link

gitguardian bot commented Dec 29, 2022

⚠️ GitGuardian has uncovered 3 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id Secret Commit Filename
5353261 RSA Private Key 2309eb5 certs/ca.key View secret
5353262 RSA Private Key 2309eb5 certs/client1.key View secret
5353263 RSA Private Key 2309eb5 certs/localhost.key View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

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.

2 participants