Update Docker Image Name + Add TODO List

This commit is contained in:
2023-09-13 08:37:49 -03:00
parent 973ba819b3
commit c9ba035589
3 changed files with 15 additions and 5 deletions

View File

@@ -6,7 +6,7 @@ Note: currently only supports docker
## Usage
1. Build: `docker build -t dockermonrs .`
1. Build: `docker build -t system-exporter .`
2. Run: `cd example && docker-compose up -d`
## Troubleshooting
@@ -14,4 +14,10 @@ Note: currently only supports docker
* If you are on OS X and using Docker Desktop, you may have to enable the docker socket. You can do this by
going to Settings -> Advanced -> Allow the default Docker socket to be used.
![docker_config.png](./img/docker_config.png)
![docker_config.png](./img/docker_config.png)
## TODO
- [ ] Add structured logging w/Slog
- [ ] Add Unit tests
- [ ] More strongly type the models

View File

@@ -13,7 +13,7 @@ services:
system-exporter:
container_name: system-exporter
image: dockermonrs
image: system-exporter
command: /app/system-exporter --docker-server http://socat:2375
ports:
- "45454:45454"

View File

@@ -39,11 +39,15 @@ async fn get_metrics(
let mut buffer = vec![];
let encoder = TextEncoder::new();
let metric_families = metrics.registry.gather();
encoder
.encode(&metric_families, &mut buffer)
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
let metrics_str = String::from_utf8(buffer).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
let mut response = Response::new(Body::from(metrics_str));
let mut response = Response::new(Body::from(
String::from_utf8(buffer).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?,
));
*response.status_mut() = StatusCode::OK;
Ok(response)
}