Skip to content

Commit

Permalink
feat: Programatically adds a docker volume on to the docker-compose t…
Browse files Browse the repository at this point in the history
…o be used for storing prometheus data
  • Loading branch information
mikirov committed Aug 2, 2024
1 parent 2fa4b82 commit 6236074
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ Cargo.lock
*.docker-compose.yml
targets.json
.idea/

prometheus_data/*
!prometheus_data/.gitkeep
5 changes: 4 additions & 1 deletion crates/cli/src/docker_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub(super) const CB_CONFIG_FILE: &str = "cb-config.toml";
pub(super) const CB_COMPOSE_FILE: &str = "cb.docker-compose.yml";
pub(super) const CB_ENV_FILE: &str = ".cb.env";
pub(super) const CB_TARGETS_FILE: &str = "targets.json"; // needs to match prometheus.yml
pub(super) const PROMETHEUS_DATA_DIR: &str = "prometheus_data";

const METRICS_NETWORK: &str = "monitoring_network";
const SIGNER_NETWORK: &str = "signer_network";
Expand Down Expand Up @@ -253,10 +254,12 @@ pub fn handle_docker_init(config_path: String, output_dir: String) -> Result<()>
let targets_volume =
Volumes::Simple(format!("./{}:/etc/prometheus/targets.json", CB_TARGETS_FILE));

let data_volume = Volumes::Simple(format!("./{}:/prometheus", PROMETHEUS_DATA_DIR));

let prometheus_service = Service {
container_name: Some("cb_prometheus".to_owned()),
image: Some("prom/prometheus:latest".to_owned()),
volumes: vec![prom_volume, targets_volume],
volumes: vec![prom_volume, targets_volume, data_volume],
// to inspect prometheus from localhost
ports: Ports::Short(vec!["9090:9090".to_owned()]),
networks: Networks::Simple(vec![METRICS_NETWORK.to_owned()]),
Expand Down
Empty file added prometheus_data/.gitkeep
Empty file.

0 comments on commit 6236074

Please sign in to comment.