Merge pull request #6526 from dokku/6440-vector-image

Allow setting the vector image as a global property
This commit is contained in:
Jose Diaz-Gonzalez
2024-01-25 04:27:49 -05:00
committed by GitHub
5 changed files with 39 additions and 8 deletions

View File

@@ -155,6 +155,27 @@ dokku logs:vector-logs --tail --num 10
The above command will show logs continually from the vector container, with an initial history of 10 log lines
#### Changing the vector image
Dokku integrates with a Vector docker image version that is known to be compatible with the documentation. In some cases, it may be useful to specify an alternative image version. To do so, set the global `vector-image` property.
```shell
dokku logs:set --global vector-image timberio/vector:0.35.X-debian
```
Once set, the vector container will need to be stopped and then started. Note that specifying the `--vector-image` flag on the `logs:vector-start` will override the setting.
```shell
dokku logs:vector-stop
dokku logs:vector-start
```
Setting this to an empty string will reset the version to the version currently compatible with the Dokku installation.
```shell
dokku logs:set --global vector-image
```
#### Configuring a log sink
Vector uses the concept of log "sinks" to send logs to a given endpoint. Log sinks may be configured globally or on a per-app basis by specifying a `vector-sink` in DSN form with the `logs:set` command. Specifying a sink value will reload any running vector container.

View File

@@ -18,8 +18,9 @@ var (
// GlobalProperties is a map of all valid global logs properties
GlobalProperties = map[string]bool{
"max-size": true,
"vector-sink": true,
"max-size": true,
"vector-image": true,
"vector-sink": true,
}
)

View File

@@ -11,11 +11,12 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
}
flags := map[string]common.ReportFunc{
"--logs-computed-max-size": reportComputedMaxSize,
"--logs-global-max-size": reportGlobalMaxSize,
"--logs-global-vector-sink": reportGlobalVectorSink,
"--logs-max-size": reportMaxSize,
"--logs-vector-sink": reportVectorSink,
"--logs-computed-max-size": reportComputedMaxSize,
"--logs-global-max-size": reportGlobalMaxSize,
"--logs-global-vector-sink": reportGlobalVectorSink,
"--logs-max-size": reportMaxSize,
"--logs-vector-global-image": reportVectorGlobalImage,
"--logs-vector-sink": reportVectorSink,
}
flagKeys := []string{}
@@ -42,6 +43,10 @@ func reportGlobalMaxSize(appName string) string {
return common.PropertyGetDefault("logs", "--global", "max-size", MaxSize)
}
func reportVectorGlobalImage(appName string) string {
return common.PropertyGetDefault("logs", "--global", "vector-image", VectorImage)
}
func reportGlobalVectorSink(appName string) string {
return common.PropertyGet("logs", "--global", "vector-sink")
}

View File

@@ -54,7 +54,7 @@ func main() {
err = logs.CommandVectorLogs(*num, *tail)
case "vector-start":
args := flag.NewFlagSet("logs:vector-start", flag.ExitOnError)
vectorImage := args.String("vector-image", logs.VectorImage, "--vector-image: the name of the docker image to run for vector")
vectorImage := args.String("vector-image", "", "--vector-image: the name of the docker image to run for vector")
args.Parse(os.Args[2:])
err = logs.CommandVectorStart(*vectorImage)
case "vector-stop":

View File

@@ -103,6 +103,10 @@ func CommandVectorStart(vectorImage string) error {
return err
}
if vectorImage == "" {
vectorImage = common.PropertyGet("logs", "--global", "vector-image")
}
if common.ContainerExists(vectorContainerName) {
if common.ContainerIsRunning(vectorContainerName) {
common.LogVerbose("Vector container is running")