Skip to content

Conversation

ajaygupta978
Copy link
Contributor

Description

This PR generates configuration for vector log collector.

/cc @vimalk78
/assign @jcantrill

@ajaygupta978
Copy link
Contributor Author

@vimalk78 This PR generates following simple config. This is just first version and there is 1-2 hard coding as of now like pipeline name. As discussed there might be some restructuring required in config.go so that pipeline names/ID can be passed to subsequent vector components.
I modified few test cases config_test.go , kafka_test.go and output_conf_kafka_test.go .

# Logs from containers (including openshift containers)
[sources.src_application]
  type = "kubernetes_logs"
  auto_partial_merge = true
  exclude_paths_glob_patterns = ["/var/log/containers/collector-*_openshift-logging_*.log", "/var/log/containers/elasticsearch-*_openshift-logging_*.log", "/var/log/containers/kibana-*_openshift-logging_*.log"]

[transforms.transform_application]
inputs = ["src_application"]
type = "remap"
source = """
. = parse_json!(.message)
.log_type = application"""

# Ship logs to specific outputs
[sinks.kafka]
type = "kafka"
input = ["transform_application"]
bootstrap_servers = "broker1-kafka.svc.messaging.cluster.local:9092"
topic = "build_complete"
sasl.enabled = false

@ajaygupta978 ajaygupta978 changed the title LOG-1491:Vector config generator LOG-1491:Vector config generator[WIP] Oct 8, 2021
@vimalk78
Copy link
Contributor

vimalk78 commented Oct 8, 2021

@ajaygupta978 if this is a Work in progress, please add [WIP] to the beginning of PR title

[WIP] LOG-1491:Vector config generator

Copy link
Contributor

@jcantrill jcantrill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there is a bunch of info here that needs to be removed for the sake of it's not fluentd

@ajaygupta978 ajaygupta978 changed the title LOG-1491:Vector config generator[WIP] WIP: LOG-1491:Vector config generator Oct 13, 2021
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 13, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 21, 2021

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ajaygupta978
To complete the pull request process, please ask for approval from jcantrill after the PR has been reviewed.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ajaygupta978
Copy link
Contributor Author

@vimalk78 @jcantrill
In previous version there was hard coding and design was also rigid because I was thinking to use fluentd design. Now in this I have changed the code and it covers application and infrastructure pipeline with Kafka output.
Apart from junit test following is kind of bit more generic pipeline specification which collects application and infra logs and send to kafka. I am adding audit pipeline and other output types.
Could you please review and let me know your comments ?

# Logs from containers
[sources.kubernetes_logs]
  type = "kubernetes_logs"
  auto_partial_merge = true
  exclude_paths_glob_patterns = ["/var/log/containers/collector-*_openshift-logging_*.log", "/var/log/containers/elasticsearch-*_openshift-logging_*.log", "/var/log/containers/kibana-*_openshift-logging_*.log"]

# Logs from journald
[sources.journald]
  type = "journald"

[transforms.transform_kubernetes_logs]
  inputs = ["kubernetes_logs"]
  type = "route"
  route.app = '!(starts_with!(.kubernetes.pod_namespace,"kube") && starts_with!(.kubernetes.pod_namespace,"openshift") && .kubernetes.pod_namespace == "default")'

[transforms.transform_journald]
  inputs = ["kubernetes_logs", "journald"]
  type = "route"
  route.infra = '(starts_with!(.kubernetes.pod_namespace,"kube") && starts_with!(.kubernetes.pod_namespace,"openshift") && .kubernetes.pod_namespace == "default")'

# Ship logs to specific outputs
[sinks.kafka]
  type = "kafka"
  input = ["transform_kubernetes_logs.app", "transform_journald.infra"]
  bootstrap_servers = "broker1-kafka.svc.messaging.cluster.local:9092"
  topic = "build_complete"
  sasl.enabled = false

@ajaygupta978
Copy link
Contributor Author

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 21, 2021
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to do this matching on CLF spec rather than the config we are trying to produce

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok will take care.

LOG-1491:Vector config generator

LOG-1491:Vector config generator

LOG-1491:Vector config generator
@ajaygupta978
Copy link
Contributor Author

@jcantrill @vimalk78 could you please review it?

LOG-1491:Vector config generator
Copy link
Contributor

@jcantrill jcantrill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There still appears to be a bunch of fluent conf here


func ConcatArrays(input []string) string {
out := make([]string, len(input))
for i, a := range input {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the input is an array string and the output is a string, why the need to spin through the input instead of just strings.Join()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was required because each of the array element needed double quote.

inputs = ["pipeline1", "pipeline2"]


for _, source := range sources {

if source.Type() == "journald" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make a constant

@@ -0,0 +1,36 @@
package vector
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run make fmt to fix formatting

instance = transform.JournalTransform{
SourceID: helpers.PipelineName("transform_" + source.Type()),
SrcType: source.ComponentID(),
InputPipeline: []string{"kubernetes_logs", helpers.PipelineName(source.Type())},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constant

[sinks.{{.StoreID}}]
type = "elasticsearch"
inputs = ` + helpers.ConcatArrays(e.InputPipeline) + `
endpoint = "{{.Host}}:{{.Port}}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might this need a protocol?

return conf
}

func generateRubyDigArgs(path string) string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not ruby so not required

pipeline = "pipeline-name"
compression = "none"
auth.strategy = "basic"
auth.user = "#{File.exists?('/var/run/ocp-collector/secrets/es-1/username') ? open('/var/run/ocp-collector/secrets/es-1/username','r') do |f|f.read end : ''}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will have to be some equivalent vector scripting not ruby


func (t TLS) Template() string {
https := `{{define "elasticsearchTLSTemplate" -}}
scheme https
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like fluentd conf

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 28, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 28, 2021

@ajaygupta978: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 12, 2021

@ajaygupta978: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/lint 9dfc152 link true /test lint
ci/prow/unit 9dfc152 link true /test unit
ci/prow/e2e 9dfc152 link true /test e2e

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@ajaygupta978
Copy link
Contributor Author

this is duplicate of #1230 so closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants