diff --git a/cmd/beyla/main.go b/cmd/beyla/main.go index 56b3a052c..caec00700 100644 --- a/cmd/beyla/main.go +++ b/cmd/beyla/main.go @@ -32,6 +32,10 @@ func main() { configPath := flag.String("config", "", "path to the configuration file") flag.Parse() + if cfg := os.Getenv("BEYLA_CONFIG_PATH"); cfg != "" { + configPath = &cfg + } + config := loadConfig(configPath) if err := lvl.UnmarshalText([]byte(config.LogLevel)); err != nil { diff --git a/deployments/03-instrumented-app.yml b/deployments/03-instrumented-app.yml index e37d9ed09..1ad0e88a9 100644 --- a/deployments/03-instrumented-app.yml +++ b/deployments/03-instrumented-app.yml @@ -55,7 +55,6 @@ spec: - name: autoinstrumenter image: grafana/beyla:main imagePullPolicy: IfNotPresent - command: ["/beyla", "--config=/config/beyla-config.yml"] securityContext: privileged: true runAsUser: 0 @@ -65,6 +64,8 @@ spec: - mountPath: /sys/kernel/security name: system-config env: + - name: BEYLA_CONFIG_PATH + value: "/config/beyla-config.yml" - name: BEYLA_SERVICE_NAME value: "goblog" - name: BEYLA_PRINT_TRACES diff --git a/docs/sources/configure/export-modes.md b/docs/sources/configure/export-modes.md index 1073a4cf2..007a43e46 100644 --- a/docs/sources/configure/export-modes.md +++ b/docs/sources/configure/export-modes.md @@ -194,8 +194,15 @@ allow exporting both metrics and traces, or only one of them to export either metrics or traces. To run the auto-instrumentation tool (previously downloaded from the [Beyla releases page](https://github.com/grafana/beyla/releases)), -you will need to specify the path to the configuration YAML file. For example `instrument-config.yml`: +you will need to specify the path to the configuration YAML file, either with the +`-config` command-line argument or the `BEYLA_CONFIG_PATH` environment variable. +For example `instrument-config.yml`: ``` beyla -config instrument-config.yml ``` +or +``` +BEYLA_CONFIG_PATH=instrument-config.yml beyla +``` + diff --git a/docs/sources/configure/options.md b/docs/sources/configure/options.md index e7276166a..69376d25a 100644 --- a/docs/sources/configure/options.md +++ b/docs/sources/configure/options.md @@ -13,14 +13,20 @@ aliases: # Beyla configuration options Beyla can be configured via environment variables or via -a YAML configuration file that is passed with the `-config` command-line -argument. Environment variables have priority over the properties in the +a YAML configuration file that is passed either with the `-config` command-line +argument or the `BEYLA_CONFIG_PATH` environment variable. +Environment variables have priority over the properties in the configuration file. For example, in the following command line, the BEYLA_OPEN_PORT option, is used to override any open_port settings inside the config.yaml file: ``` $ BEYLA_OPEN_PORT=8080 beyla -config /path/to/config.yaml ``` +or +``` +$ BEYLA_OPEN_PORT=8080 BEYLA_CONFIG_PATH=/path/to/config.yaml beyla +``` + At the end of this document, there is an [example of YAML configuration file](#yaml-file-example). diff --git a/docs/sources/distributed-traces.md b/docs/sources/distributed-traces.md index 497ab1636..c21f532a6 100644 --- a/docs/sources/distributed-traces.md +++ b/docs/sources/distributed-traces.md @@ -46,9 +46,8 @@ services: ... beyla: image: grafana/beyla:latest - command: - - /beyla - - --config=/configs/beyla-config.yml + environment: + BEYLA_CONFIG_PATH: "/configs/beyla-config.yml" volumes: - /sys/kernel/security:/sys/kernel/security ``` diff --git a/docs/sources/quickstart/cpp.md b/docs/sources/quickstart/cpp.md index 4eda4cd80..826115047 100644 --- a/docs/sources/quickstart/cpp.md +++ b/docs/sources/quickstart/cpp.md @@ -111,7 +111,7 @@ routes: unmatched: heuristic ``` -Then, run Beyla with the `-config` argument: +Then, run Beyla with the `-config` argument (or use the `BEYLA_CONFIG_PATH` environment variable instead): ``` sudo -E beyla -config config.yml diff --git a/docs/sources/quickstart/golang.md b/docs/sources/quickstart/golang.md index 5abe86923..2747dad72 100644 --- a/docs/sources/quickstart/golang.md +++ b/docs/sources/quickstart/golang.md @@ -122,7 +122,7 @@ routes: unmatched: heuristic ``` -Then, run Beyla with the `-config` argument: +Then, run Beyla with the `-config` argument (or use the `BEYLA_CONFIG_PATH` environment variable instead): ``` sudo -E beyla -config config.yml diff --git a/docs/sources/quickstart/nodejs.md b/docs/sources/quickstart/nodejs.md index 34bac11e0..dd49396a8 100644 --- a/docs/sources/quickstart/nodejs.md +++ b/docs/sources/quickstart/nodejs.md @@ -121,7 +121,7 @@ routes: unmatched: heuristic ``` -Then, run Beyla with the `-config` argument: +Then, run Beyla with the `-config` argument (or use the `BEYLA_CONFIG_PATH` environment variable instead): ``` sudo -E beyla -config config.yml diff --git a/docs/sources/quickstart/python.md b/docs/sources/quickstart/python.md index 2aeb50517..e8d8b18d4 100644 --- a/docs/sources/quickstart/python.md +++ b/docs/sources/quickstart/python.md @@ -119,7 +119,7 @@ routes: unmatched: heuristic ``` -Then, run Beyla with the `-config` argument: +Then, run Beyla with the `-config` argument (or use the `BEYLA_CONFIG_PATH` environment variable instead): ``` sudo -E beyla -config config.yml diff --git a/docs/sources/quickstart/ruby.md b/docs/sources/quickstart/ruby.md index 4f5cb4fc9..e4ab6dad0 100644 --- a/docs/sources/quickstart/ruby.md +++ b/docs/sources/quickstart/ruby.md @@ -119,7 +119,7 @@ routes: unmatched: heuristic ``` -Then, run Beyla with the `-config` argument: +Then, run Beyla with the `-config` argument (or use the `BEYLA_CONFIG_PATH` environment variable instead): ``` sudo -E beyla -config config.yml diff --git a/docs/sources/quickstart/rust.md b/docs/sources/quickstart/rust.md index 284188aa6..92ec288e2 100644 --- a/docs/sources/quickstart/rust.md +++ b/docs/sources/quickstart/rust.md @@ -107,7 +107,7 @@ routes: unmatched: heuristic ``` -Then, run Beyla with the `-config` argument: +Then, run Beyla with the `-config` argument (or use the `BEYLA_CONFIG_PATH` environment variable instead): ``` sudo -E beyla -config config.yml diff --git a/docs/sources/setup/kubernetes.md b/docs/sources/setup/kubernetes.md index 4db541a39..accbac635 100644 --- a/docs/sources/setup/kubernetes.md +++ b/docs/sources/setup/kubernetes.md @@ -245,7 +245,7 @@ this site). To provide the configuration as a file, the recommended way is to deploy a ConfigMap with the intended configuration, then mount it into the Beyla -Pod, and refer to it by overriding the Beyla container command. +Pod, and refer to it with the `BEYLA_CONFIG_PATH` environment variable. Example of ConfigMap with the Beyla YAML documentation: @@ -302,8 +302,11 @@ spec: volumeMounts: - mountPath: /config name: beyla-config - # tell beyla where to find the configuration file - command: ["/beyla", "--config=/config/beyla-config.yml"] + env: + # tell beyla where to find the configuration file + - name: BEYLA_CONFIG_PATH + value: "/config/beyla-config.yml" + ``` ## Providing secret configuration diff --git a/docs/sources/tutorial/k8s-walkthrough.md b/docs/sources/tutorial/k8s-walkthrough.md index 10e45f551..a72d57551 100644 --- a/docs/sources/tutorial/k8s-walkthrough.md +++ b/docs/sources/tutorial/k8s-walkthrough.md @@ -301,13 +301,14 @@ spec: - name: beyla image: grafana/beyla:main imagePullPolicy: IfNotPresent - command: ["/beyla", "--config=/config/beyla-config.yml"] securityContext: privileged: true # mandatory! volumeMounts: - mountPath: /config name: beyla-config env: + - name: BEYLA_CONFIG_PATH + value: "/config/beyla-config.yml" - name: OTEL_EXPORTER_OTLP_ENDPOINT valueFrom: secretKeyRef: diff --git a/examples/greeting-apps/docker-compose.yaml b/examples/greeting-apps/docker-compose.yaml index 724984634..884580032 100644 --- a/examples/greeting-apps/docker-compose.yaml +++ b/examples/greeting-apps/docker-compose.yaml @@ -19,9 +19,6 @@ services: # Beyla for NGINX nginxbeyla: image: grafana/beyla:latest - command: - - /beyla - - --config=/configs/beyla-config.yml volumes: - ./configs/:/configs - ./system/sys/kernel/security:/sys/kernel/security @@ -30,6 +27,7 @@ services: network_mode: "service:nginx" pid: "service:nginx" environment: + BEYLA_CONFIG_PATH: "/configs/beyla-config.yml" BEYLA_PRINT_TRACES: "true" BEYLA_OPEN_PORT: "3330" BEYLA_SERVICE_NAMESPACE: "demo" @@ -51,9 +49,6 @@ services: # Beyla for Java Spring Boot 3.0 GraalVM Native Image gobeyla: image: grafana/beyla:latest - command: - - /beyla - - --config=/configs/beyla-config.yml volumes: - ./configs/:/configs - ./system/sys/kernel/security:/sys/kernel/security @@ -62,6 +57,7 @@ services: network_mode: "service:gotestserver" pid: "service:gotestserver" environment: + BEYLA_CONFIG_PATH: "/configs/beyla-config.yml" BEYLA_PRINT_TRACES: "true" BEYLA_OPEN_PORT: "8080" BEYLA_SERVICE_NAMESPACE: "demo" @@ -83,9 +79,6 @@ services: # Beyla for Java Spring Boot 3.0 GraalVM Native Image javabeyla: image: grafana/beyla:latest - command: - - /beyla - - --config=/configs/beyla-config.yml volumes: - ./configs/:/configs - ./system/sys/kernel/security:/sys/kernel/security @@ -94,6 +87,7 @@ services: network_mode: "service:javatestserver" pid: "service:javatestserver" environment: + BEYLA_CONFIG_PATH: "/configs/beyla-config.yml" BEYLA_PRINT_TRACES: "true" BEYLA_OPEN_PORT: "8085" BEYLA_SERVICE_NAMESPACE: "demo" @@ -115,9 +109,6 @@ services: # Beyla for Rust Actix rustbeyla: image: grafana/beyla:latest - command: - - /beyla - - --config=/configs/beyla-config.yml volumes: - ./configs/:/configs - ./system/sys/kernel/security:/sys/kernel/security @@ -126,6 +117,7 @@ services: network_mode: "service:rusttestserver" pid: "service:rusttestserver" environment: + BEYLA_CONFIG_PATH: "/configs/beyla-config.yml" BEYLA_PRINT_TRACES: "true" BEYLA_OPEN_PORT: "8090" BEYLA_SERVICE_NAMESPACE: "demo" diff --git a/test/integration/docker-compose-1.16.yml b/test/integration/docker-compose-1.16.yml index 694a61d13..5c14ddf54 100644 --- a/test/integration/docker-compose-1.16.yml +++ b/test/integration/docker-compose-1.16.yml @@ -17,9 +17,6 @@ services: build: context: ../.. dockerfile: ./test/integration/components/beyla/Dockerfile - command: - - /beyla - - --config=/configs/instrumenter-config-java.yml volumes: - ./configs/:/configs - ../../testoutput:/coverage @@ -28,6 +25,7 @@ services: privileged: true # in some environments (not GH Pull Requests) you can set it to false and then cap_add: [ SYS_ADMIN ] pid: "service:testserver" environment: + BEYLA_CONFIG_PATH: "/configs/instrumenter-config-java.yml" GOCOVERDIR: "/coverage" BEYLA_PRINT_TRACES: "true" BEYLA_OPEN_PORT: 8080 diff --git a/test/integration/docker-compose-java-host.yml b/test/integration/docker-compose-java-host.yml index ddff9a4b5..b461e5d49 100644 --- a/test/integration/docker-compose-java-host.yml +++ b/test/integration/docker-compose-java-host.yml @@ -12,9 +12,6 @@ services: build: context: ../.. dockerfile: ./test/integration/components/beyla/Dockerfile - command: - - /beyla - - --config=/configs/instrumenter-config-java-host.yml volumes: - ./configs/:/configs - ./system/sys/kernel/security:/sys/kernel/security @@ -25,6 +22,7 @@ services: network_mode: "host" pid: "host" environment: + BEYLA_CONFIG_PATH: "/configs/instrumenter-config-java-host.yml" GOCOVERDIR: "/coverage" BEYLA_PRINT_TRACES: "true" BEYLA_OPEN_PORT: "${JAVA_OPEN_PORT}" diff --git a/test/integration/docker-compose-java-pid.yml b/test/integration/docker-compose-java-pid.yml index 28800bdd7..c7a2d2153 100644 --- a/test/integration/docker-compose-java-pid.yml +++ b/test/integration/docker-compose-java-pid.yml @@ -12,9 +12,6 @@ services: build: context: ../.. dockerfile: ./test/integration/components/beyla/Dockerfile - command: - - /beyla - - --config=/configs/instrumenter-config-java.yml volumes: - ./configs/:/configs - ./system/sys/kernel/security:/sys/kernel/security @@ -25,6 +22,7 @@ services: network_mode: "service:testserver" pid: "service:testserver" environment: + BEYLA_CONFIG_PATH: "/configs/instrumenter-config-java.yml" GOCOVERDIR: "/coverage" BEYLA_PRINT_TRACES: "true" BEYLA_OPEN_PORT: "${JAVA_OPEN_PORT}" diff --git a/test/integration/docker-compose-java-system-wide.yml b/test/integration/docker-compose-java-system-wide.yml index dd057979d..44378c966 100644 --- a/test/integration/docker-compose-java-system-wide.yml +++ b/test/integration/docker-compose-java-system-wide.yml @@ -25,9 +25,6 @@ services: build: context: ../.. dockerfile: ./test/integration/components/beyla/Dockerfile - command: - - /beyla - - --config=/configs/instrumenter-config-java.yml volumes: - ./configs/:/configs - ../../testoutput:/coverage @@ -37,6 +34,7 @@ services: network_mode: "service:testserver" pid: "host" environment: + BEYLA_CONFIG_PATH: "/configs/instrumenter-config-java.yml" GOCOVERDIR: "/coverage" BEYLA_PRINT_TRACES: "true" BEYLA_OPEN_PORT: "${JAVA_OPEN_PORT}" diff --git a/test/integration/docker-compose-python.yml b/test/integration/docker-compose-python.yml index c031f8a1d..567c26c6b 100644 --- a/test/integration/docker-compose-python.yml +++ b/test/integration/docker-compose-python.yml @@ -16,9 +16,6 @@ services: build: context: ../.. dockerfile: ./test/integration/components/beyla/Dockerfile - command: - - /beyla - - --config=/configs/instrumenter-config-java.yml volumes: - ./configs/:/configs - ./system/sys/kernel/security:/sys/kernel/security @@ -29,6 +26,7 @@ services: network_mode: "service:testserver" pid: "service:testserver" environment: + BEYLA_CONFIG_PATH: "/configs/instrumenter-config-java.yml" GOCOVERDIR: "/coverage" BEYLA_PRINT_TRACES: "true" BEYLA_OPEN_PORT: "${BEYLA_OPEN_PORT}" diff --git a/test/integration/k8s/manifests/05-instrumented-service-otel.yml b/test/integration/k8s/manifests/05-instrumented-service-otel.yml index 9acbbdb6c..890b49040 100644 --- a/test/integration/k8s/manifests/05-instrumented-service-otel.yml +++ b/test/integration/k8s/manifests/05-instrumented-service-otel.yml @@ -83,6 +83,8 @@ spec: - mountPath: /testoutput name: testoutput env: + - name: BEYLA_CONFIG_PATH + value: "/configs/instrumenter-config.yml" - name: GOCOVERDIR value: "/testoutput" - name: BEYLA_PRINT_TRACES diff --git a/test/integration/k8s/manifests/05-instrumented-service-prometheus.yml b/test/integration/k8s/manifests/05-instrumented-service-prometheus.yml index 94566db82..9d8d7cbfb 100644 --- a/test/integration/k8s/manifests/05-instrumented-service-prometheus.yml +++ b/test/integration/k8s/manifests/05-instrumented-service-prometheus.yml @@ -89,13 +89,14 @@ spec: imagePullPolicy: Never # loaded into Kind from localhost securityContext: privileged: true - command: ["/beyla", "--config=/configs/instrumenter-config-promscrape.yml"] volumeMounts: - mountPath: /configs name: configs - mountPath: /testoutput name: testoutput env: + - name: BEYLA_CONFIG_PATH + value: "/configs/instrumenter-config-promscrape.yml" - name: GOCOVERDIR value: "/testoutput" - name: BEYLA_DISCOVERY_POLL_INTERVAL