Skip to content

Commit

Permalink
Merge pull request #693 from AlexAi27/dev_logbeat_container_with_mult…
Browse files Browse the repository at this point in the history
…i_configs

logbeat-sidecar
  • Loading branch information
DeveloperJim authored Dec 10, 2020
2 parents 11648d6 + 311df15 commit a3bfb47
Show file tree
Hide file tree
Showing 11 changed files with 389 additions and 87 deletions.
2 changes: 2 additions & 0 deletions bcs-services/bcs-logbeat-sidecar/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ func setConfig(conf *config.Config, op *options.SidecarOption) {
conf.TemplateFile = op.TemplateFile
conf.LogbeatDir = op.LogbeatDir
conf.Kubeconfig = op.Kubeconfig
conf.EvalSymlink = op.EvalSymlink
conf.LogbeatPIDFilePath = op.LogbeatPIDFilePath
}
12 changes: 7 additions & 5 deletions bcs-services/bcs-logbeat-sidecar/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ type SidecarOption struct {
conf.LogConfig
conf.ProcessConfig

DockerSock string `json:"docker_sock" value:"unix:///var/run/docker.sock" usage:"docker socket file"`
LogbeatDir string `json:"logbeat_dir" value:"" usage:"logbeat config directory"`
TemplateFile string `json:"template_file" value:"./unifytlogc-template.conf" usage:"logbeat tempalte config file"`
PrefixFile string `json:"prefix_file" value:"" usage:"logbeat config file prefix name"`
Kubeconfig string `json:"kubeconfig" value:"" usage:"kubeconfig"`
DockerSock string `json:"docker_sock" value:"unix:///var/run/docker.sock" usage:"docker socket file"`
LogbeatDir string `json:"logbeat_dir" value:"" usage:"logbeat config directory"`
TemplateFile string `json:"template_file" value:"./unifytlogc-template.conf" usage:"logbeat tempalte config file"`
PrefixFile string `json:"prefix_file" value:"" usage:"logbeat config file prefix name"`
Kubeconfig string `json:"kubeconfig" value:"" usage:"kubeconfig"`
EvalSymlink bool `json:"eval_symlink" value:"false" usage:"whether to enable remove symbol link in the log path"`
LogbeatPIDFilePath string `json:"logbeat_pid_file_path" value:"" usage:"logbeat PID file path, which is used to reload logbeat"`
}

//NewSidecarOption create SidecarOption object
Expand Down
5 changes: 5 additions & 0 deletions bcs-services/bcs-logbeat-sidecar/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ type Config struct {
PrefixFile string
//kube-apiserver config file path
Kubeconfig string
// whether to enable remove symbol link in the log path
// this should be false if deployed as in-cluster mode
EvalSymlink bool
// logbeat PID file path
LogbeatPIDFilePath string
}

//NewConfig create a config object
Expand Down
5 changes: 5 additions & 0 deletions bcs-services/bcs-logbeat-sidecar/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ replace (

require (
github.com/Tencent/bk-bcs v0.0.0-20200805130634-8a6c639f4a4c
github.com/containerd/containerd v1.4.3 // indirect
github.com/docker/docker v20.10.0-rc1+incompatible // indirect
github.com/fsouza/go-dockerclient v1.6.5
github.com/moby/sys/mount v0.2.0 // indirect
github.com/prometheus/client_golang v1.7.1
github.com/prometheus/client_model v0.2.0
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
gopkg.in/yaml.v2 v2.3.0
gotest.tools/v3 v3.0.3 // indirect
k8s.io/api v0.18.6
k8s.io/apiextensions-apiserver v0.18.6
k8s.io/apimachinery v0.18.6
Expand Down
6 changes: 4 additions & 2 deletions bcs-services/bcs-logbeat-sidecar/metric/logfileinfo_guage.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import (
)

var (
logFileInfoGaugeLabelNames = []string{"clusterID", "crdName", "crdNamespace", "hostIP", "containerID", "podName", "podNamespace", "workloadType", "workloadName", "workloadNamespace"}
logFileInfoGaugeLabelNames = []string{"clusterID", "crdName", "crdNamespace", "hostIP", "containerID",
"podName", "podNamespace", "workloadType", "workloadName", "workloadNamespace"}
// LogFileInfoGauge is container log collection task Gauge metric
LogFileInfoGauge *prometheus.GaugeVec
)
Expand All @@ -47,7 +48,8 @@ func init() {
LogFileInfoGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "logbeat_sidecar_logfile_gen_info",
Help: "logbeat_sidecar_logfile_gen_info has labels describing the infomation of logfile and gauge value 0/1 corresponds to (logfile generated/logfile does not generated)",
Help: "logbeat_sidecar_logfile_gen_info has labels describing the information" +
" of logfile and gauge value 0/1 corresponds to (logfile generated/logfile does not generated)",
},
logFileInfoGaugeLabelNames,
)
Expand Down
Loading

0 comments on commit a3bfb47

Please sign in to comment.