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

Observability otel demo #185

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

YANG-DB
Copy link
Member

@YANG-DB YANG-DB commented May 30, 2023

Description

adding an Observability OpenTelemetry Demo being a part of the Observability playground deployment

Issues Resolved

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

 - data-prepper
 - nginx
 - fluentBit
 - jaeger
 - otel-col

Signed-off-by: YANGDB <yang.db.dev@gmail.com>
 - data-prepper
 - nginx
 - fluentBit
 - jaeger
 - otel-col

Signed-off-by: YANGDB <yang.db.dev@gmail.com>
…servability-otel-demo

# Conflicts:
#	config/playground/demo/observability/otel_demo/jaeger.yaml
- queries
- dashboards

Once they are loaded, the user can imminently review his OTEL demo services and dashboards that reflect the system state.
Copy link
Member

Choose a reason for hiding this comment

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

the user can imminently review the OTEL demo services, should we remove 'his' here.

METRICS_STORAGE_TYPE: "prometheus"
SPAN_STORAGE_TYPE: "opensearch"
ES_TAGS_AS_FIELDS_ALL: "true"
ES_USERNAME: "admin"
Copy link
Member

Choose a reason for hiding this comment

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

can we use variable here? thanks

input-nginx.conf: |
[INPUT]
Name tail
Tag nginx.*
Copy link
Member

Choose a reason for hiding this comment

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

frontend.access for tag. this is workable version for yesterday. I forgot to copy the yesterday's version

Refresh_Interval 10
[FILTER]
Name parser
Match nginx.access
Copy link
Member

Choose a reason for hiding this comment

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

frontend.access for match too

Parser nginx
[FILTER]
Name lua
Match nginx.access
Copy link
Member

Choose a reason for hiding this comment

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

frontend.access for match too.

[FILTER]
Name lua
Match nginx.access
code function cb_filter(a,b,c)local d={}local e=os.date("!%Y-%m-%dT%H:%M:%S.000Z")d["observerTime"]=e;d["body"]=c.remote.." "..c.host.." "..c.user.." ["..os.date("%d/%b/%Y:%H:%M:%S %z").."] \""..c.method.." "..c.path.." HTTP/1.1\" "..c.code.." "..c.size.." \""..c.referer.."\" \""..c.agent.."\""d["trace_id"]="102981ABCD2901"d["span_id"]="abcdef1010"d["attributes"]={}d["attributes"]["data_stream"]={}d["attributes"]["data_stream"]["dataset"]="nginx.access"d["attributes"]["data_stream"]["namespace"]="production"d["attributes"]["data_stream"]["type"]="logs"d["event"]={}d["event"]["category"]={"web"}d["event"]["name"]="access"d["event"]["domain"]="nginx.access"d["event"]["kind"]="event"d["event"]["result"]="success"d["event"]["type"]={"access"}d["http"]={}d["http"]["request"]={}d["http"]["request"]["method"]=c.method;d["http"]["response"]={}d["http"]["response"]["bytes"]=tonumber(c.size)d["http"]["response"]["status_code"]=c.code;d["http"]["flavor"]="1.1"d["http"]["url"]=c.path;d["communication"]={}d["communication"]["source"]={}d["communication"]["source"]["address"]="127.0.0.1"d["communication"]["source"]["ip"]=c.remote;return 1,b,d end
Copy link
Member

Choose a reason for hiding this comment

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

        code    function cb_filter(a,b,c)local d={}local e=os.date("!%Y-%m-%dT%H:%M:%S.000Z")d["observerTime"]=e;d["body"]=c.remote.." "..c.host.." "..c.user.." ["..os.date("%d/%b/%Y:%H:%M:%S %z").."] \""..c.method.." "..c.path.." HTTP/1.1\" "..c.code.." "..c.size.." \""..c.referer.."\" \""..c.agent.."\""d["trace_id"]="102981ABCD2901"d["span_id"]="abcdef1010"d["attributes"]={}d["attributes"]["data_stream"]={}d["attributes"]["data_stream"]["dataset"]="frontend.access"d["attributes"]["data_stream"]["namespace"]="production"d["attributes"]["data_stream"]["type"]="logs"d["event"]={}d["event"]["category"]={"web"}d["event"]["name"]="access"d["event"]["domain"]="frontend.access"d["event"]["kind"]="event"d["event"]["result"]="success"d["event"]["type"]={"access"}d["http"]={}d["http"]["request"]={}d["http"]["request"]["method"]=c.method;d["http"]["response"]={}d["http"]["response"]["bytes"]=tonumber(c.size)d["http"]["response"]["status_code"]=c.code;d["http"]["flavor"]="1.1"d["http"]["url"]=c.path;d["communication"]={}d["communication"]["source"]={}d["communication"]["source"]["address"]="127.0.0.1"d["communication"]["source"]["ip"]=c.remote;return 1,b,d end

Logstash_Prefix sso_logs-nginx-prod
[OUTPUT]
Name stdout
Match nginx.access
Copy link
Member

Choose a reason for hiding this comment

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

frontend.access for match

Format json
Time_Key time
Time_Format %Y-%m-%dT%H:%M:%S.%L
Time_Keep On
Copy link
Member

Choose a reason for hiding this comment

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

We don't need parser for json

---
# Nginx Deployment
apiVersion: apps/v1
kind: Deployment
Copy link
Member

Choose a reason for hiding this comment

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

This is workable version from yesterday

# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
---
# Nginx Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  namespace: otel-demo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:latest
          ports:
            - containerPort: 90
          volumeMounts:
            - name: config-volume
              mountPath: /etc/nginx/conf.d/default.conf
              subPath: default.conf
            - name: log-storage
              mountPath: /var/log/nginx/
        - name: fluent-bit
          image: fluent/fluent-bit
          env:
            - name: OPENSEARCH_HOST
              value: "opensearch-cluster-leader.default.svc"
            - name: OPENSEARCH_USER
              value: "{USR}"
            - name: OPENSEARCH_PWD
              value: "{PSWD}"
          volumeMounts:
            - name: log-storage
              mountPath: /var/log/
            - name: fluent-bit-config
              mountPath: /fluent-bit/etc/
      restartPolicy: Always
      volumes:
        - name: config-volume
          configMap:
            name: nginx-config
            items:
              - key: default.conf
                path: default.conf
        - name: opentelemetry-volume
          configMap:
            name: nginx-config
            items:
              - key: opentelemetry_module.conf
                path: opentelemetry_module.conf
        - name: log-storage
          emptyDir: {}
        - name: fluent-bit-config
          configMap:
            name: fluent-bit-sidecar-config
---
# Nginx Config-map
apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-config
  namespace: otel-demo
data:
  default.conf: |
    server {
      listen 90;
      access_log /var/log/nginx/frontend.access.log;
      error_log /var/log/nginx/frontend.error.log;
      location / {
         proxy_pass http://opentelemetry-demo-frontend:8080/;
         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header X-Forwarded-Proto $scheme;
       }
    }
---
# fluent-bit Config-map
apiVersion: v1
kind: ConfigMap
metadata:
  name: fluent-bit-sidecar-config
  namespace: otel-demo
  labels:
    app: nginx
data:
  fluent-bit.conf: |
    [SERVICE]
        Flush         1
        Log_Level     info
        Daemon        off
        Parsers_File  parsers.conf
        Log_Level     debug
    @INCLUDE input-nginx.conf
    @INCLUDE output-opensearch.conf
  input-nginx.conf: |
    [INPUT]
        Name              tail
        Tag               frontend.access
        Path              /var/log/*.log
        DB                /var/log/flb_kube.db
        Parser            nginx
        Mem_Buf_Limit     5MB
        Skip_Long_Lines   On
        Refresh_Interval  10
    [FILTER]
        Name parser
        Match frontend.access
        Key_Name log
        Parser nginx
    [FILTER]
        Name    lua
        Match   frontend.access
        code    function cb_filter(a,b,c)local d={}local e=os.date("!%Y-%m-%dT%H:%M:%S.000Z")d["observerTime"]=e;d["body"]=c.remote.." "..c.host.." "..c.user.." ["..os.date("%d/%b/%Y:%H:%M:%S %z").."] \""..c.method.." "..c.path.." HTTP/1.1\" "..c.code.." "..c.size.." \""..c.referer.."\" \""..c.agent.."\""d["trace_id"]="102981ABCD2901"d["span_id"]="abcdef1010"d["attributes"]={}d["attributes"]["data_stream"]={}d["attributes"]["data_stream"]["dataset"]="frontend.access"d["attributes"]["data_stream"]["namespace"]="production"d["attributes"]["data_stream"]["type"]="logs"d["event"]={}d["event"]["category"]={"web"}d["event"]["name"]="access"d["event"]["domain"]="frontend.access"d["event"]["kind"]="event"d["event"]["result"]="success"d["event"]["type"]={"access"}d["http"]={}d["http"]["request"]={}d["http"]["request"]["method"]=c.method;d["http"]["response"]={}d["http"]["response"]["bytes"]=tonumber(c.size)d["http"]["response"]["status_code"]=c.code;d["http"]["flavor"]="1.1"d["http"]["url"]=c.path;d["communication"]={}d["communication"]["source"]={}d["communication"]["source"]["address"]="127.0.0.1"d["communication"]["source"]["ip"]=c.remote;return 1,b,d end
        call    cb_filter
  output-opensearch.conf: |
    [OUTPUT]
        Name                opensearch
        Match               *
        Host                ${OPENSEARCH_HOST}
        tls.verify          Off
        tls                 On
        HTTP_User           ${OPENSEARCH_USER}
        HTTP_Passwd         ${OPENSEARCH_PWD}
        Suppress_Type_Name  On
        Generate_ID         On
        Logstash_Format     On
        Logstash_Prefix     sso_logs-nginx-prod
    [OUTPUT]
        Name stdout
        Match frontend.access
  parsers.conf: |
    [PARSER]
        Name        nginx
        Format      regex
        Regex       ^(?<remote>[^ ]*) (?<host>[^ ]*) (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^\"]*?)(?: +\S*)?)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)")
        Time_Key    time
        Time_Format %d/%b/%Y:%H:%M:%S %z
---
# Nginx Service
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  namespace: otel-demo
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 90
      targetPort: 90

… cluster

Signed-off-by: YANGDB <yang.db.dev@gmail.com>
… cluster

Signed-off-by: YANGDB <yang.db.dev@gmail.com>
…servability-otel-demo

# Conflicts:
#	config/playground/demo/observability/otel_demo/integrations.yaml
…servability-otel-demo

Signed-off-by: YANGDB <yang.db.dev@gmail.com>

# Conflicts:
#	config/playground/demo/observability/otel_demo/integrations.yaml
…servability-otel-demo

Signed-off-by: YANGDB <yang.db.dev@gmail.com>

# Conflicts:
#	config/playground/demo/observability/otel_demo/integrations.yaml
…servability-otel-demo

Signed-off-by: YANGDB <yang.db.dev@gmail.com>

# Conflicts:
#	config/playground/demo/observability/otel_demo/integrations.yaml
…servability-otel-demo

Signed-off-by: YANGDB <yang.db.dev@gmail.com>

# Conflicts:
#	config/playground/demo/observability/otel_demo/integrations.yaml
@lezzago lezzago mentioned this pull request Dec 6, 2023
1 task
…servability-otel-demo

Signed-off-by: YANGDB <yang.db.dev@gmail.com>

# Conflicts:
#	config/playground/demo/observability/otel_demo/integrations.yaml
Signed-off-by: YANGDB <yang.db.dev@gmail.com>
Signed-off-by: YANGDB <yang.db.dev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants