Already have metrics server installed?
Install Better Stack chart without metrics server using code block above.
Alternatively, set metrics-server.enabled=false
in values.yaml
.
How do you want to integrate Better Stack with your Kubernetes cluster?
Add Better Stack Helm repository:
helm repo add betterstack-logs https://betterstackhq.github.io/logs-helm-chart
helm repo update
Create values.yaml
config file with the following contents:
vector:
customConfig:
sinks:
better_stack_http_sink:
auth:
strategy: "bearer"
token: "$SOURCE_TOKEN"
better_stack_http_metrics_sink:
auth:
strategy: "bearer"
token: "$SOURCE_TOKEN"
# config for Minikube with disabled TLS
vector:
customConfig:
sinks:
better_stack_http_sink:
auth:
strategy: "bearer"
token: $SOURCE_TOKEN
better_stack_http_metrics_sink:
auth:
strategy: "bearer"
token: $SOURCE_TOKEN
sources:
better_stack_kubernetes_metrics_nodes:
tls:
verify_certificate: false
verify_hostname: false
better_stack_kubernetes_metrics_pods:
tls:
verify_certificate: false
verify_hostname: false
metrics-server:
args:
- --kubelet-insecure-tls
Install the Better Stack chart:
helm install betterstack-logs betterstack-logs/betterstack-logs -f values.yaml
helm install betterstack-logs betterstack-logs/betterstack-logs -f values.yaml \
--set metrics-server.enabled=false
Install Better Stack chart without metrics server using code block above.
Alternatively, set metrics-server.enabled=false
in values.yaml
.
You should see your logs in Better Stack → Live tail.
Check out your metrics in the Kubernetes dashboard.
Kubernetes version 1.15 or higher is required.
Please let us know at hello@betterstack.com.
We're happy to help! 🙏
Install Kubernetes Metrics Server into your cluster:
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.6.4/components.yaml
Create namespace configuration file:
kubectl create namespace --dry-run=client -o yaml vector > namespace.yaml
Save the following config as kustomization.yaml
:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
# Override the namespace of all of the resources we manage.
namespace: vector
images:
# Override the Vector image to pin the version used.
- name: timberio/vector
newName: timberio/vector
newTag: 0.33.0-distroless-libc
resources:
# The namespace previously created to keep the resources in.
- namespace.yaml
# RBAC config allowing Vector access to metrics and creating a Secret with the service account.
- rbac.yaml
# Include Vector recommended base (from git).
- github.com/vectordotdev/vector/distribution/kubernetes/vector-agent
configMapGenerator:
# ConfigMap with Vector config.
- name: vector
behavior: replace
files:
- vector-agent.yaml
patches:
# Prevent data dir read-only volume mount issue: https://github.com/vectordotdev/helm-charts/issues/226
# Set volumeMount readOnly: false
# Also, add vector SA token into an ENV variable, Vector will use it to connect to metrics-server
- patch: |-
- op: replace
path: /spec/template/spec/containers/0/volumeMounts/3/readOnly
value: false
- op: add
path: /spec/template/spec/containers/0/env/-
value:
name: SERVICE_ACCOUNT_TOKEN
valueFrom:
secretKeyRef:
name: vector-service-account
key: token
target:
group: apps
version: v1
kind: DaemonSet
name: vector
Save the following config as rbac.yaml
to allow Vector to access the Metrics Server:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: vector-metrics
labels:
app.kubernetes.io/name: vector
app.kubernetes.io/instance: vector
app.kubernetes.io/component: Agent
rules:
- apiGroups:
- "metrics.k8s.io"
resources:
- nodes
- pods
verbs:
- list
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: vector-metrics
labels:
app.kubernetes.io/name: vector
app.kubernetes.io/instance: vector
app.kubernetes.io/component: Agent
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: vector-metrics
subjects:
- kind: ServiceAccount
name: vector
namespace: vector
---
apiVersion: v1
kind: Secret
metadata:
name: vector-service-account
annotations:
kubernetes.io/service-account.name: "vector"
type: kubernetes.io/service-account-token
Download Vector configuration for your source:
curl -o vector-agent.yaml \
https://telemetry.betterstack.com/vector-yaml/kubernetes/$SOURCE_TOKEN
Reload Vector configuration and restart it:
kubectl apply -k .
kubectl rollout restart -n vector daemonset/vector
You should see your logs in Better Stack → Live tail.
Check out your metrics in the Kubernetes dashboard.
Kubernetes version 1.15 or higher is required.
Using Minikube to test the setup?
Disable certificate validation to prevent TLS errors:
--kubelet-insecure-tls
to args
config of metrics-server
DaemonSettls.verify_certificate = false
and tls.verify_hostname = false
to all http_client
sources in vector-agent.yaml
Please let us know at hello@betterstack.com.
We're happy to help! 🙏
Interested in reading about installing and configuring Vector in more detail?
Check out the official Vector Kubernetes installation guide.
Want an overview of different tools for monitoring Kubernetes?
Head to comparison of best Kubernetes monitoring tools.
Customize your Vector configuration by adding a Vector filter transform between the better_stack_http_sink
sink and its original inputs:
vector:
customConfig:
sinks:
better_stack_http_sink:
inputs: [better_stack_http_filter]
auth:
strategy: "bearer"
token: $SOURCE_TOKEN
better_stack_http_metrics_sink:
auth:
strategy: "bearer"
token: $SOURCE_TOKEN
transforms:
better_stack_http_filter:
type: "filter"
inputs: [better_stack_kubernetes_parser]
condition: .kubernetes.container_name == "my_important_container"
sources:
# ...
transforms:
better_stack_kubernetes_parser_$SOURCE_TOKEN:
# ...
better_stack_http_filter_$SOURCE_TOKEN:
type: "filter"
inputs: [better_stack_kubernetes_parser_$SOURCE_TOKEN]
condition: .kubernetes.container_name == "my_important_container"
sinks:
better_stack_http_sink_$SOURCE_TOKEN:
type: "http"
method: "post"
uri: "https://in.logs.betterstack.com/"
encoding:
codec: "json"
auth:
strategy: "bearer"
token: "$SOURCE_TOKEN"
inputs: ["better_stack_http_filter_$SOURCE_TOKEN"]
better_stack_http_metrics_sink_$SOURCE_TOKEN:
# ...