Home System Tutorial LINUX Elaborate on using Splunk to monitor Kubernetes performance

Elaborate on using Splunk to monitor Kubernetes performance

Jul 26, 2024 pm 05:31 PM
linux linux tutorial Red Hat linux system linux command linux certification red hat linux linux video

Deployment Architecture

The picture below shows the deployment architecture of this solution, which mainly includes:

Use Heapster to collect K8s performance data, including CPU, Memory, Network, File System, etc.

Use Heapster’s Statsd Sink to send data to Splunk’s Metrics Store

Use Splunk’s search commands and dashboard functions to monitor performance data
Elaborate on using Splunk to monitor Kubernetes performance

Preparation

There are two main things to prepare in the early stage:

Compile the latest Heapster image and upload it to a public Docker image repository, such as docker hub

Configure Metrics Store and corresponding network input (Network Input UDP/TCP) in Splunk

The main choice here is whether to use UDP or TCP for Statsd’s transmission protocol. Here I recommend using TCP. The latest Heapster code supports different Backends, including log, influxdb, stackdriver, gcp monitoring, gcp logging, statsd, hawkular-metrics, wavefront, openTSDB, kafka, riemann, elasticsearch, etc. Because Splunk's Metrics Store supports the statsd protocol, it can be easily integrated with Heapster.

First we need to use the latest heapster code to compile a container image, because the official image of heapsterd on docker hub is older and does not support statsd. So you need to compile it yourself.

mkdir myheapster
mkdir myheapster/src
export GOPATH=myheapster
cd myheapster/src
git clone https://github.com/kubernetes/heapster.git
cd heapster
make container
Copy after login

Run the above command to compile the latest heapster image.

Note that heapster uses udp protocol by default. If you want to use tcp, you need to modify the code

https://github.com/kubernetes/heapster/blob/master/metrics/sinks/statsd/statsd_client.go

func (client *statsdClientImpl) open() error {
	var err error
	client.conn, err = net.Dial("udp", client.host)
	if err != nil {
		glog.Errorf("Failed to open statsd client connection : %v", err)
	} else {
		glog.V(2).Infof("statsd client connection opened : %+v", client.conn)
	}
	return err
}
Copy after login

Change udp to tcp.

I have placed two images on docker hub, corresponding to the udp version and the tcp version respectively. You can use them directly

naughtytao/heapster-amd64:v1.5.0-beta.3 udp

naughtytao/heapster-amd64:v1.5.0-beta.4 tcp

Then you need to configure Metrics Store in Splunk, refer to this document
Elaborate on using Splunk to monitor Kubernetes performance

Install and configure Heapster

It is relatively easy to deploy heapster on K8s. Just create the corresponding yaml configuration file and then use the kubectl command line to create it.

The following are the configuration files of Deployment and Service:

deployment.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: heapster
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        task: monitoring
        k8s-app: heapster
        version: v6
    spec:
      containers:
      - name: heapster
        image: naughtytao/heapster-amd64:v1.5.0-beta.3
        imagePullPolicy: Always
        command:
        - /heapster
        - --source=kubernetes:https://kubernetes.default
        - --sink=statsd:udp://ip:port?numMetricsPerMsg=1
Copy after login

service.yaml

apiVersion: v1
kind: Service
metadata:
  labels:
    task: monitoring
    # For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)
    # If you are NOT using this as an addon, you should comment out this line.
    kubernetes.io/cluster-service: 'true'
    kubernetes.io/name: Heapster
  name: heapster
  namespace: kube-system
spec:
  ports:
  - port: 80
    targetPort: 8082
  selector:
    k8s-app: heapster
Copy after login

Pay attention to the deployment--sink configuration here. IP is the IP or host name of Splunk, and port corresponds to the port number of Splunk's data input. When using the udp protocol, the value of numMetricsPerMsg that needs to be configured is relatively small. When this value is relatively large, a message too long error will appear. Larger values ​​can be configured when using tcp.

Run kubectl apply -f *.yaml to deploy heapster

If it runs normally, the corresponding log of the heapster pod is as follows

I0117 18:10:56.054746       1 heapster.go:78] /heapster --source=kubernetes:https://kubernetes.default --sink=statsd:udp://ec2-34-203-25-154.compute-1.amazonaws.com:8124?numMetricsPerMsg=10
I0117 18:10:56.054776       1 heapster.go:79] Heapster version v1.5.0-beta.4
I0117 18:10:56.054963       1 configs.go:61] Using Kubernetes client with master "https://kubernetes.default" and version v1
I0117 18:10:56.054978       1 configs.go:62] Using kubelet port 10255
I0117 18:10:56.076200       1 driver.go:104] statsd metrics sink using configuration : {host:ec2-34-203-25-154.compute-1.amazonaws.com:8124 prefix: numMetricsPerMsg:10 protocolType:etsystatsd renameLabels:map[] allowedLabels:map[] customizeLabel:0x15fc8c0}
I0117 18:10:56.076248       1 driver.go:104] statsd metrics sink using configuration : {host:ec2-34-203-25-154.compute-1.amazonaws.com:8124 prefix: numMetricsPerMsg:10 protocolType:etsystatsd renameLabels:map[] allowedLabels:map[] customizeLabel:0x15fc8c0}
I0117 18:10:56.076272       1 heapster.go:202] Starting with StatsD Sink
I0117 18:10:56.076281       1 heapster.go:202] Starting with Metric Sink
I0117 18:10:56.090229       1 heapster.go:112] Starting heapster on port 8082
Copy after login
Monitoring in Splunk

Okay, if everything goes normally, heapster will send metrics to Splunk's metrics store using the statsd protocol and format.

Then you can use the mstats and mcatalog commands of SPL to analyze and monitor the metrics data.

The following search statement lists all Metrics

| mcatalog values(metric_name)
Copy after login

Elaborate on using Splunk to monitor Kubernetes performance

The following search statement lists the CPU usage of the entire cluster. We can use Area or Line Chart to visualize the search results.

| mstats avg(_value) WHERE metric_name=cluster.cpu/usage_rate span=30m
Copy after login

Elaborate on using Splunk to monitor Kubernetes performance

Corresponding memory usage of kube-system namespace

| mstats avg(_value) WHERE metric_name=namespace.kube-system.memory/usage span=30m
Copy after login

Elaborate on using Splunk to monitor Kubernetes performance

You can put the analysis results you are interested in in the Dashboard and use Realtime settings for monitoring.
Elaborate on using Splunk to monitor Kubernetes performance

Okay, for more analysis options, please refer to the Splunk documentation.

The above is the detailed content of Elaborate on using Splunk to monitor Kubernetes performance. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What computer configuration is required for vscode What computer configuration is required for vscode Apr 15, 2025 pm 09:48 PM

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

vscode cannot install extension vscode cannot install extension Apr 15, 2025 pm 07:18 PM

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

vscode terminal usage tutorial vscode terminal usage tutorial Apr 15, 2025 pm 10:09 PM

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

Can vscode be used for mac Can vscode be used for mac Apr 15, 2025 pm 07:36 PM

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.

See all articles