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

Enable configuring Prometheus metrics port for local runs #377

Merged

Conversation

kate-goldenring
Copy link
Contributor

What this PR does / why we need it:
When running Akri locally (rather than in containers), the Controller and Agent try to use the same address for Prometheus metrics. This enables configuring the port with a METRICS_PORT environment variable creating a scenario like the following:

Run controller (specifying metrics run on localhost:8081):

cargo build -p controller
RUST_LOG=info METRICS_PORT=8081 KUBECONFIG=~/test.cluster.config ./target/debug/controller

Run agent (specifying metrics run on localhost:8082):

cargo build -p agent
sudo DEBUG_ECHO_INSTANCES_SHARED=true ENABLE_DEBUG_ECHO=1 RUST_LOG=info METRICS_PORT=8082 KUBECONFIG=~/test.cluster.config DISCOVERY_HANDLERS_DIRECTORY=~/tmp/akri AGENT_NODE_NAME=myNode HOST_CRICTL_PATH=/usr/bin/crictl HOST_RUNTIME_ENDPOINT=/var/run/dockershim.sock HOST_IMAGE_ENDPOINT=/var/run/dockershim.sock ./target/debug/agent

Special notes for your reviewer:
If approved, I can add notes on configuring this to our development doc.

If applicable:

  • this PR has an associated PR with documentation in akri-docs
  • this PR contains unit tests
  • added code adheres to standard Rust formatting (cargo fmt)
  • code builds properly (cargo build)
  • code is free of common mistakes (cargo clippy)
  • all Akri tests succeed (cargo test)
  • inline documentation builds (cargo doc)
  • version has been updated appropriately (./version.sh)

@bfjelds
Copy link
Collaborator

bfjelds commented Sep 10, 2021

this seems fine to me. would it make sense to leave run_metrics_server as a no-param method and have this code inside it:

    let port = match std::env::var(METRICS_PORT_LABEL) {
        Ok(p) => p.parse::<u16>()?,
        Err(_) => 8080,
    };

@kate-goldenring
Copy link
Contributor Author

this seems fine to me. would it make sense to leave run_metrics_server as a no-param method and have this code inside it:

    let port = match std::env::var(METRICS_PORT_LABEL) {
        Ok(p) => p.parse::<u16>()?,
        Err(_) => 8080,
    };

@bfjelds great point. Made the change

@kate-goldenring kate-goldenring merged commit 134fcb0 into project-akri:main Sep 15, 2021
@kate-goldenring kate-goldenring deleted the configure-metrics-port branch September 15, 2021 22:56
vincepnguyen pushed a commit that referenced this pull request Nov 23, 2021
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