|
| 1 | +--- |
| 2 | +title: "Local Observability Setup" |
| 3 | +--- |
| 4 | +This document lists necessary steps to enable observability features in Bytechef server and start up supporting observability tools in development mode. With the provided configuration, the user gains insight into Metrics, Logs, and Traces. |
| 5 | + |
| 6 | +### Metrics |
| 7 | + |
| 8 | +By including the following dependencies we have enabled metrics in the Bytchef server. |
| 9 | +```kotlin |
| 10 | +implementation("org.springframework.boot:spring-boot-actuator") |
| 11 | +implementation("io.micrometer:micrometer-registry-prometheus") |
| 12 | +``` |
| 13 | +Spring Boot Actuator, using Micrometer, generates a predefined set of metrics. The Micrometer Prometheus registry has a task of formatting these metrics into a Prometheus readable format. Such metrics are available on `/actuator/prometheus` endpoint. |
| 14 | +For gathering and processing of metrics data we are using Prometheus, which development configuration can be found in [prometheus-dev.yml](https://github.com/bytechefhq/bytechef/tree/master/server/ee/docker/prometheus/prometheus-dev.yml). |
| 15 | + |
| 16 | +### Logs |
| 17 | +We use Loki to aggregate and store logs. Logs are sent to Loki by Loki4jAppender which is configured in the [logback-spring.xml](https://github.com/bytechefhq/bytechef/tree/master/server/libs/config/logback-config/src/main/resources/logback-spring.xml) |
| 18 | + |
| 19 | +Loki's URL is defined via `bytechef.observability.loki.appender.http.url` Spring property. Additionally, we can control log level which will be sent to Loki via `bytechef.observability.loki.appender.level`. |
| 20 | +```yaml |
| 21 | +bytechef: |
| 22 | + observability: |
| 23 | + loki: |
| 24 | + appender: |
| 25 | + level: "ALL" |
| 26 | + http: |
| 27 | + url: http://localhost:3100/loki/api/v1/push |
| 28 | +``` |
| 29 | +
|
| 30 | +In logback-spring.xml it is also defined how Loki indexes logs. |
| 31 | +```xml |
| 32 | + <label> |
| 33 | + <pattern>app=${applicationName},host=${HOSTNAME},traceID=%X{traceId:-NONE},level=%level</pattern> |
| 34 | +</label> |
| 35 | +``` |
| 36 | +This means you can efficiently filter logs by applicationName, host, level or traceID. |
| 37 | + |
| 38 | +Loki development configuration is defined in a [loki-dev.yml](https://github.com/bytechefhq/bytechef/tree/master/server/ee/docker/loki/loki-dev.yml) file where, among other things, filesystem is defined as a log storage. |
| 39 | + |
| 40 | +### Traces |
| 41 | + |
| 42 | +Traces allow us to follow a request as it traverses Bytechef microservices. Tracing in Bytechef is enabled by including the following dependencies. |
| 43 | +```kotlin |
| 44 | +implementation("io.micrometer:micrometer-tracing-bridge-otel") |
| 45 | +implementation("io.opentelemetry:opentelemetry-exporter-otlp") |
| 46 | +``` |
| 47 | +`micrometer-tracing-bridge-otel` bridges the Micrometer Observation API to OpenTelemetry format while `io.opentelemetry:opentelemetry-exporter-otlp` reports traces to a collector that can accept OTLP. |
| 48 | + |
| 49 | +We use Tempo as a tracing backend, which distributor and ingester support Open Telemetry. Tempo's development configuration is located in [tempo-dev.yml](https://github.com/bytechefhq/bytechef/tree/master/server/ee/docker/tempo/tempo-dev.yml) |
| 50 | + |
| 51 | +### Grafana |
| 52 | + |
| 53 | +We use Grafana to visualize all the data from the observability backends. Grafana is available locally at http://localhost:3000/explore. |
| 54 | + |
| 55 | +### Bytechef observability local setup |
| 56 | + |
| 57 | +1. Start up the Grafana observability stack |
| 58 | + - in the terminal navigate to `server/ee/docker`. |
| 59 | + - run `docker-compose -f monitoring.yml up` |
| 60 | + |
| 61 | +2. Enable observability features in Bytechef |
| 62 | + - Start Bytechef with updated Spring property `bytechef.observability.enabled` set to `true`. |
0 commit comments