Skip to content

Commit

Permalink
LogDNA Output support (#530)
Browse files Browse the repository at this point in the history
* - Logdna support update
- rebase
* Update
* Rebase/generate
  • Loading branch information
ahma committed Jul 20, 2020
1 parent b461887 commit 991de96
Show file tree
Hide file tree
Showing 29 changed files with 646 additions and 6 deletions.
4 changes: 4 additions & 0 deletions charts/logging-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ The following tables lists the configurable parameters of the logging-demo chart
| `cloudwatch.aws.region` | AWS CLoudWatch Region | `` |
| `cloudwatch.aws.log_group_name` | AWS CLoudWatch Log Group | `` |
| `cloudwatch.aws.log_stream_name` | AWS CLoudWatch Log Stream | `` |
| `logdna.enabled` | Enable LogDNA logging output | `false` |
| `logdna.api_key` | LogDNA Api key | `` |
| `logdna.hostname` | Hostname | `` |
| `logdna.app` | Application name | `` |
| `logGenerator.enabled` | Enable Demo Log-Gen application | `true` |
| `loggingOperator.tls.enabled` | Enabled TLS communication between components | `true` |
| `loggingOperator.tls.fluentdSecretName` | Specified secret name, which contain tls certs | This will overwrite automatic Helm certificate generation. |
Expand Down
5 changes: 4 additions & 1 deletion charts/logging-demo/templates/flow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
app.kubernetes.io/instance: {{ .Release.Name }}
outputRefs:

{{- if or .Values.file.enabled (and (not .Values.cloudwatch.enabled) (not .Values.elasticsearch.enabled) (not .Values.kafka.enabled) (not .Values.loki.enabled) (not .Values.minio.enabled)) }}
{{- if or .Values.file.enabled (and (not .Values.cloudwatch.enabled) (not .Values.elasticsearch.enabled) (not .Values.kafka.enabled) (not .Values.loki.enabled) (not .Values.minio.enabled) (not .Values.logdna.enabled)) }}
- {{ include "output.fullname" . }}-file
{{- end }}
{{- if .Values.cloudwatch.enabled }}
Expand All @@ -38,4 +38,7 @@ spec:
{{- if .Values.minio.enabled }}
- {{ include "output.fullname" . }}-minio
{{- end }}
{{- if .Values.logdna.enabled }}
- {{ include "output.fullname" . }}-logdna
{{- end }}

2 changes: 1 addition & 1 deletion charts/logging-demo/templates/output_file.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if or .Values.file.enabled (and (not .Values.cloudwatch.enabled) (not .Values.elasticsearch.enabled) (not .Values.kafka.enabled) (not .Values.loki.enabled) (not .Values.minio.enabled)) }}
{{- if or .Values.file.enabled (and (not .Values.cloudwatch.enabled) (not .Values.elasticsearch.enabled) (not .Values.kafka.enabled) (not .Values.loki.enabled) (not .Values.minio.enabled) (not .Values.logdna.enabled)) }}
apiVersion: logging.banzaicloud.io/v1beta1
kind: Output
metadata:
Expand Down
15 changes: 15 additions & 0 deletions charts/logging-demo/templates/output_logdna.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if and .Values.logdna.enabled }}
apiVersion: logging.banzaicloud.io/v1beta1
kind: Output
metadata:
name: {{ include "output.fullname" . }}-logdna
namespace: {{ .Release.Namespace }}
labels:
{{ include "logging-demo.labels" . | indent 4 }}
spec:
logdna:
api_key: {{ .Values.logdna.api_key }}
{{/* hostname: {{ .Values.logdna.hostname }}*/}}
hostname: "$.kubernetes.host"
app: {{ .Values.logdna.app }}
{{- end }}
7 changes: 7 additions & 0 deletions charts/logging-demo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ cloudwatch:
log_group_name: ""
log_stream_name: ""

# Enable LogDNA logging output
logdna:
enabled: false
api_key: ""
app: ""
hostname: ""

# Enable Demo Log-Gen application
logGenerator:
enabled: true
Original file line number Diff line number Diff line change
Expand Up @@ -4493,6 +4493,26 @@ spec:
required:
- stream_name
type: object
logdna:
description: Send your logs to LogDNA
properties:
api_key:
description: LogDNA Api key
type: string
app:
description: Application name
type: string
buffer_chunk_limit:
description: Do not increase past 8m (8MB) or your logs will be
rejected by LogDNA server.
type: string
hostname:
description: Hostname
type: string
required:
- api_key
- hostname
type: object
loggingRef:
type: string
logz:
Expand Down
20 changes: 20 additions & 0 deletions charts/logging-operator/crds/logging.banzaicloud.io_outputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4489,6 +4489,26 @@ spec:
required:
- stream_name
type: object
logdna:
description: Send your logs to LogDNA
properties:
api_key:
description: LogDNA Api key
type: string
app:
description: Application name
type: string
buffer_chunk_limit:
description: Do not increase past 8m (8MB) or your logs will be
rejected by LogDNA server.
type: string
hostname:
description: Hostname
type: string
required:
- api_key
- hostname
type: object
loggingRef:
type: string
logz:
Expand Down
20 changes: 20 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4493,6 +4493,26 @@ spec:
required:
- stream_name
type: object
logdna:
description: Send your logs to LogDNA
properties:
api_key:
description: LogDNA Api key
type: string
app:
description: Application name
type: string
buffer_chunk_limit:
description: Do not increase past 8m (8MB) or your logs will be
rejected by LogDNA server.
type: string
hostname:
description: Hostname
type: string
required:
- api_key
- hostname
type: object
loggingRef:
type: string
logz:
Expand Down
20 changes: 20 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_outputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4489,6 +4489,26 @@ spec:
required:
- stream_name
type: object
logdna:
description: Send your logs to LogDNA
properties:
api_key:
description: LogDNA Api key
type: string
app:
description: Application name
type: string
buffer_chunk_limit:
description: Do not increase past 8m (8MB) or your logs will be
rejected by LogDNA server.
type: string
hostname:
description: Hostname
type: string
required:
- api_key
- hostname
type: object
loggingRef:
type: string
logz:
Expand Down
1 change: 1 addition & 0 deletions docs/crds/v1beta1/output_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ generated_file: true
| kafka | *output.KafkaOutputConfig | No | - | |
| cloudwatch | *output.CloudWatchOutput | No | - | |
| kinesisStream | *output.KinesisStreamOutputConfig | No | - | |
| logdna | *output.LogDNAOutput | No | - | |
| newrelic | *output.NewRelicOutputConfig | No | - | |
| splunkHec | *output.SplunkHecOutput | No | - | |
| http | *output.HTTPOutputConfig | No | - | |
Expand Down
133 changes: 133 additions & 0 deletions docs/example-logdna-nginx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<p align="center"><img src="./img/logdna.svg" width="340"></p>

# Store Nginx Access Logs in LogDNA with Logging Operator

<p align="center"><img src="./img/nginx-logdna.svg" width="900"></p>

---
## Contents
- **Installation**
- **Logging Operator**
- [Deploy with Helm](#install-with-helm)
- [Deploy with Kubernetes Manifests](#install-from-kubernetes-manifests)
- **Demo Application**
- [Deploy with Helm](#demo-app-and-logging-definition)
- [Deploy with Kubernetes Manifests](#install-from-kubernetes-manifests)
- **Validation**
- [LogDNA Dashboard](#logdna-dashboard)
---
<br />

## Deploy Logging-Operator with Demo Application

### Install with Helm
#### Add operator chart repository:
```bash
helm repo add banzaicloud-stable https://kubernetes-charts.banzaicloud.com
helm repo update
```
#### Logging Operator
> [How to install Logging-operator with helm](./deploy/README.md#deploy-logging-operator-with-helm)
#### Demo App and Logging Definition
```bash
helm install --namespace logging --name logging-demo banzaicloud-stable/logging-demo \
--set "logdna.enabled=True" \
--set "logdna.api_key=" \
--set "logdna.app=" \
--set "logdna.hostname="
```
---
<br />


### Install from Kubernetes manifests
#### Logging Operator
> [How to install Logging-operator from manifests](./deploy/README.md#deploy-logging-operator-from-kubernetes-manifests)
#### Create `logging` Namespace
```bash
kubectl create ns logging
```

#### Create `logging` resource
```bash
kubectl -n logging apply -f - <<"EOF"
apiVersion: logging.banzaicloud.io/v1beta1
kind: Logging
metadata:
name: demo-logging
spec:
fluentd: {}
fluentbit: {}
controlNamespace: logging
EOF
```
> Note: `ClusterOutput` and `ClusterFlow` resource will only be accepted in the `controlNamespace`

#### Create a LogDNA `Output` Definition
```bash
kubectl -n logging apply -f - <<"EOF"
apiVersion: logging.banzaicloud.io/v1beta1
kind: Output
metadata:
name: logdna-output
namespace: logging
spec:
logdna:
api_key: demoa0315076d75234133124fd2f583demo
hostname: logging-operator
app: my-app
EOF
```

#### Create `flow` resource
```bash
kubectl -n logging apply -f - <<"EOF"
apiVersion: logging.banzaicloud.io/v1beta1
kind: Flow
metadata:
name: nginx-log-to-logdna
spec:
filters:
- tag_normaliser: {}
- parser:
remove_key_name_field: true
reserve_data: true
parsers:
- type: nginx
selectors:
app.kubernetes.io/name: log-generator
outputRefs:
- logdna-output
EOF
```

#### Install Demo Deployment
```bash
kubectl -n logging apply -f - <<"EOF"
apiVersion: apps/v1
kind: Deployment
metadata:
name: log-generator
spec:
selector:
matchLabels:
app.kubernetes.io/name: log-generator
replicas: 1
template:
metadata:
labels:
app.kubernetes.io/name: log-generator
spec:
containers:
- name: nginx
image: banzaicloud/log-generator:0.3.2
EOF
```

## LogDNA Dashboard
<p align="center"><img src="./img/Screenshot-logdna.png" width="660"></p>


9 changes: 9 additions & 0 deletions docs/examples/logging_output_logdna.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: logging.banzaicloud.io/v1beta1
kind: Output
metadata:
name: logdna-output-sample
spec:
logdna:
api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxx
hostname: logging-operator
app: my-app
Binary file added docs/img/Screenshot-logdna.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/img/logdna.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 991de96

Please sign in to comment.