Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BEYLA_CONFIG_PATH env var #549

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/beyla/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion deployments/03-instrumented-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion docs/sources/configure/export-modes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

10 changes: 8 additions & 2 deletions docs/sources/configure/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
5 changes: 2 additions & 3 deletions docs/sources/distributed-traces.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/quickstart/cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/quickstart/golang.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/quickstart/nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/quickstart/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/quickstart/ruby.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/quickstart/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions docs/sources/setup/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion docs/sources/tutorial/k8s-walkthrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 4 additions & 12 deletions examples/greeting-apps/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions test/integration/docker-compose-1.16.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions test/integration/docker-compose-java-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
Expand Down
4 changes: 1 addition & 3 deletions test/integration/docker-compose-java-pid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
Expand Down
4 changes: 1 addition & 3 deletions test/integration/docker-compose-java-system-wide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
Expand Down
4 changes: 1 addition & 3 deletions test/integration/docker-compose-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down