Skip to content

Commit 424efc6

Browse files
committed
feat(actors): expose container system metrics
1 parent d26363d commit 424efc6

File tree

98 files changed

+2283
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2283
-206
lines changed

docker/dev-full/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ services:
233233
# We only reserve 100 ports instead of the default 22,000. See
234234
# rivet-guard for explanation.
235235
- "7600-7699:7600-7699"
236+
# cAdvisor metrics endpoint
237+
- "7780:7780"
236238
networks:
237239
- rivet-network
238240

docker/dev-full/otel-collector/config.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ receivers:
55
endpoint: 0.0.0.0:4317
66
http:
77
endpoint: 0.0.0.0:4318
8+
prometheus:
9+
config:
10+
scrape_configs:
11+
- job_name: 'cadvisor'
12+
static_configs:
13+
- targets: ['rivet-client:7780']
14+
metrics_path: /metrics
15+
scrape_interval: 30s
816

917
processors:
1018
batch:
@@ -52,7 +60,7 @@ service:
5260
processors: [batch]
5361
exporters: [clickhouse]
5462
metrics:
55-
receivers: [otlp]
63+
receivers: [otlp, prometheus]
5664
processors: [batch]
5765
exporters: [clickhouse]
5866

docker/universal/Dockerfile

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ RUN apt-get update -y && \
120120
apt-get install -y ca-certificates openssl curl tini curl && \
121121
curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.1.60/libfdb_c.x86_64.so"
122122

123-
# MARK: Runner (Full)
124-
FROM --platform=linux/amd64 base-runner AS client-full
123+
# MARK: Runner (Slim)
124+
FROM --platform=linux/amd64 base-runner AS client-slim
125125
ARG CNI_PLUGINS_VERSION=1.3.0
126126
RUN apt-get install -y skopeo iproute2 runc dnsutils && \
127127
echo "Downloading lz4" && \
@@ -142,6 +142,23 @@ COPY ./docker/dev-full/rivet-client/rivet-actor.conflist /opt/cni/config/rivet-a
142142
COPY --from=builder /app/dist/rivet-client /app/dist/rivet-container-runner /usr/local/bin/
143143
ENTRYPOINT ["/usr/bin/tini", "--", "entrypoint.sh"]
144144

145+
# MARK: Runner (Full)
146+
FROM client-slim AS client-full
147+
ARG CADVISOR_VERSION=v0.52.0
148+
RUN apt-get update -y && \
149+
apt-get install -y wget && \
150+
wget -O /usr/local/bin/cadvisor "https://github.com/google/cadvisor/releases/download/${CADVISOR_VERSION}/cadvisor-${CADVISOR_VERSION}-linux-amd64" && \
151+
chmod +x /usr/local/bin/cadvisor && \
152+
apt-get clean && \
153+
rm -rf /var/lib/apt/lists/*
154+
155+
COPY docker/universal/client-full-entrypoint.sh /usr/local/bin/client-full-entrypoint.sh
156+
RUN chmod +x /usr/local/bin/client-full-entrypoint.sh
157+
158+
EXPOSE 7780
159+
160+
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/client-full-entrypoint.sh"]
161+
145162
# MARK: Monlith
146163
FROM --platform=linux/amd64 debian:12.9-slim AS monolith
147164
ENV DEBIAN_FRONTEND=noninteractive
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Start cadvisor in the background
5+
cadvisor \
6+
--port=7780 \
7+
--listen_ip=0.0.0.0 \
8+
--prometheus_endpoint="/metrics" \
9+
--enable_metrics=cpu,cpuLoad,memory,network,disk,diskIO,oom_event,process,tcp,udp \
10+
--docker_only=false \
11+
--disable_root_cgroup_stats=false &
12+
13+
# TODO:
14+
# --raw_cgroup_prefix_whitelist="" \
15+
16+
# Start rivet-client with all passed arguments
17+
exec rivet-client "$@"

packages/common/api-helper/build/src/macro_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ pub fn __deserialize_query<T: DeserializeOwned + Send>(route: &Url) -> GlobalRes
237237
}
238238

239239
#[doc(hidden)]
240-
#[tracing::instrument(skip_all, name="setup_ctx")]
240+
#[tracing::instrument(skip_all, name = "setup_ctx")]
241241
pub async fn __with_ctx<
242242
A: auth::ApiAuth + Send,
243243
DB: chirp_workflow::db::Database + Sync + 'static,

packages/common/clickhouse-inserter/src/error.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ use thiserror::Error;
22

33
#[derive(Debug, Error)]
44
pub enum Error {
5-
#[error("failed to send event to ClickHouse inserter")]
6-
ChannelSendError,
5+
#[error("failed to send event to ClickHouse inserter")]
6+
ChannelSendError,
77

8-
#[error("serialization error: {0}")]
9-
SerializationError(#[source] serde_json::Error),
8+
#[error("serialization error: {0}")]
9+
SerializationError(#[source] serde_json::Error),
1010

11-
#[error("failed to build reqwest client: {0}")]
12-
ReqwestBuildError(#[source] reqwest::Error),
11+
#[error("failed to build reqwest client: {0}")]
12+
ReqwestBuildError(#[source] reqwest::Error),
1313

14-
#[error("failed to spawn background task")]
15-
TaskSpawnError,
16-
}
14+
#[error("failed to spawn background task")]
15+
TaskSpawnError,
16+
}

packages/common/config/src/config/server/rivet/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl Rivet {
177177
}
178178
}
179179

180-
impl Rivet {
180+
impl Rivet {
181181
pub fn default_cluster_id(&self) -> GlobalResult<Uuid> {
182182
if let Some(default_cluster_id) = self.default_cluster_id {
183183
ensure!(
@@ -190,7 +190,9 @@ impl Rivet {
190190
// Return default development clusters
191191
AccessKind::Development => Ok(default_dev_cluster::CLUSTER_ID),
192192
// No cluster configured
193-
AccessKind::Public | AccessKind::Private => bail!("`default_cluster_id` not configured"),
193+
AccessKind::Public | AccessKind::Private => {
194+
bail!("`default_cluster_id` not configured")
195+
}
194196
}
195197
}
196198
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name = "ACTOR_METRICS_INVALID_METRICS"
3+
description = "Invalid metrics format."
4+
http_status = 400
5+
---
6+
7+
# Invalid Metrics
8+
9+
The provided list of metrics is not in a valid JSON format. Please provide a valid JSON array of metric names.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name = "ACTOR_METRICS_NO_METRICS"
3+
description = "No metrics specified."
4+
http_status = 400
5+
---
6+
7+
# No Metrics
8+
9+
No metrics were specified in the request. Please provide at least one metric name to query.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name = "ACTOR_METRICS_UNSUPPORTED_METRICS"
3+
description = "Unsupported metrics requested."
4+
http_status = 400
5+
---
6+
7+
# Unsupported Metrics
8+
9+
The requested metrics are not supported. Supported metrics include: cpu, memory, memory_limit, network_rx_bytes, network_tx_bytes.

0 commit comments

Comments
 (0)