Merge pull request #7878 from dokku/7758-base64-encoded-vector-values

Allow specifying base64-encoded values in vector-sink DSN urls
This commit is contained in:
Jose Diaz-Gonzalez authored and GitHub committed 2025-08-23 18:19:26 -04:00
commit 68d5b5c986
5 files changed
+58 -1

No files matched your search

+13
View File
@@ -234,6 +234,19 @@ For some sinks - such as the `http` sink - it may be useful to use special chara
dokku logs:set test vector-sink "http://?uri=https%3A//loggerservice.com%3A1234/%3Ftoken%3Dabc1234%26type%3Dvector" dokku logs:set test vector-sink "http://?uri=https%3A//loggerservice.com%3A1234/%3Ftoken%3Dabc1234%26type%3Dvector"
``` ```
For kubernetes, it may be necessary to use template syntax - `{{ .parent.child }}` - in the sink configuration. Naively using brackets will fail due to the Helm chart install process assuming that the template should be interpreted at Helm install time vs by Vector itself. To avoid this, use `base64enc:` values (available only for top-level properties at this time). The following example shows how to use `{{ pod }}` as a value.
```shell
# encode the value with a Helm `print` statement wrapper
encoded="$(echo '{{ print "{{ pod }}" }}' | base64)"
# the value of encoded should be: e3sgcHJpbnQgInt7IHBvZCB9fSIgfX0K
# set the value
dokku logs:set test vector-sink "http://?process=base64enc%3A${encoded}"
```
This will transform the value to it's encoded form when configuring Vector sinks for Kubernetes.
Please read the [sink documentation](https://vector.dev/docs/reference/configuration/sinks/) for your sink of choice to configure the sink as desired. Please read the [sink documentation](https://vector.dev/docs/reference/configuration/sinks/) for your sink of choice to configure the sink as desired.
##### Configuring the app label ##### Configuring the app label
+1
View File
@@ -611,6 +611,7 @@ Next, run the `scheduler-k3s:ensure-charts` command with the `vector` chart to f
```shell ```shell
dokku scheduler-k3s:ensure-charts --charts vector dokku scheduler-k3s:ensure-charts --charts vector
``` ```
Please see the [vector logs documentation](/docs/deployment/logs.md#configuring-a-log-sink) for more information on specifying vector sinks.
### Supported Resource Management Properties ### Supported Resource Management Properties
+17
View File
@@ -2,6 +2,7 @@ package logs
import ( import (
"embed" "embed"
"encoding/base64"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
@@ -102,5 +103,21 @@ func SinkValueToConfig(appName string, sinkValue string) (VectorSink, error) {
data["inputs"] = []string{"docker-null-source"} data["inputs"] = []string{"docker-null-source"}
} }
// add special support for `base64enc:VAL` fields
for key, value := range data {
valueString, ok := value.(string)
if !ok {
continue
}
if encodedValue, found := strings.CutPrefix(valueString, "base64enc:"); found {
decodedValue, err := base64.StdEncoding.DecodeString(encodedValue)
if err != nil {
return data, fmt.Errorf("Error decoding base64: %w", err)
}
data[key] = strings.TrimSpace(string(decodedValue))
}
}
return data, nil return data, nil
} }
+1 -1
View File
@@ -1577,7 +1577,7 @@ func installHelmCharts(ctx context.Context, clientset KubernetesClient, shouldIn
} }
} }
if chart.ReleaseName == "vector" { if chart.ReleaseName == "vector" && chart.Namespace == "vector" {
values = updateVectorValues(values) values = updateVectorValues(values)
} }
+26
View File
@@ -52,6 +52,32 @@ teardown_() {
assert_output "2" assert_output "2"
} }
@test "(scheduler-k3s) deploy kustomize with vector sink" {
if [[ -z "$DOCKERHUB_USERNAME" ]] || [[ -z "$DOCKERHUB_TOKEN" ]]; then
skip "skipping due to missing docker.io credentials DOCKERHUB_USERNAME:DOCKERHUB_TOKEN"
fi
encoded="$(echo '{{ print "{{ pod }}" }}' | base64)"
run /bin/bash -c "echo $encoded"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "e3sgcHJpbnQgInt7IHBvZCB9fSIgfX0K"
run /bin/bash -c "dokku logs:set --global vector-sink 'http://?process=base64enc%3A${encoded}'"
echo "output: $output"
echo "status: $status"
assert_success
INGRESS_CLASS=nginx install_k3s
run /bin/bash -c "kubectl get cm -n vector vector -o yaml"
echo "output: $output"
echo "status: $status"
assert_success
assert_output_contains "process: '{{ pod }}'"
}
inject_kustomization_yaml() { inject_kustomization_yaml() {
local APP="$1" local APP="$1"
local APP_REPO_DIR="$2" local APP_REPO_DIR="$2"