MCPcopy Index your code
hub / github.com/GuanceCloud/datakit

github.com/GuanceCloud/datakit @9.9.9

Chat with this repo
repository ↗ · DeepWiki ↗ · release 9.9.9 ↗ · + Follow
9,226 symbols 33,352 edges 1,251 files 1,671 documented · 18%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

DataKit

datakit logo

Slack Status MIT License FOSSA Status

官网 文档

DataKit 是一款开源、一体式的数据采集 Agent,它提供全平台操作系统(Linux/Windows/macOS)支持,拥有全面数据采集能力,涵盖主机、容器、中间件、Tracing、日志以及安全巡检等各种场景。

主要功能点

发布历史

DataKit 发布历史参见这里.

操作系统最低要求

操作系统 架构 安装路径
Linux 内核 2.6.23 或更高版本 amd64/386/arm/arm64 /usr/local/datakit
macOS 10.12 或更高版本(原因) amd64 /usr/local/datakit
Windows 7, Server 2008R2 或更高版本 amd64/386 64位:C:\Program Files\datakit

32位:C:\Program Files(32)\datakit |

DataKit 安装

我们可以直接在观测云平台获取 DataKit 安装命令,主流平台的安装命令大概如下:

  • Linux & Mac
DK_DATAWAY="https://openway.guance.com?token=<YOUR-TOKEN>" bash -c "$(curl -L https://static.guance.com/datakit/install.sh)"
  • Windows
Remove-Item -ErrorAction SilentlyContinue Env:DK_*;
$env:DK_DATAWAY="https://openway.guance.com?token=<YOUR-TOKEN>";
Set-ExecutionPolicy Bypass -scope Process -Force;
Import-Module bitstransfer;
start-bitstransfer -source https://static.guance.com/datakit/install.ps1 -destination .install.ps1;
powershell .install.ps1;
Remove-Item .install.ps1;

更多关于安装的文档,参见这里

源码编译

DataKit 开发过程中依赖了一些外部工具,我们必须先将这些工具准备好才能比较顺利的编译 DataKit。

  • 建议在 Ubuntu 20.04+ 下编译 DataKit, 其它 Linux 发行版在安装这些依赖时可能会碰到困难。另外,不建议在 Windows 上编译
  • 请在命令行终端运行 make,暂时尚未针对 Goland/VSCode 等做编译适配
  • 先安装这些依赖,然后再 clone 代码。如果在 DataKit 代码目录来安装这些依赖,可能导致一些 vendor 库拉取的问题

设置 Golang

设置 Go 编译环境

Go-1.18.3 及以上版本

export GOPRIVATE=gitlab.jiagouyun.com/*
export GOPROXY=https://goproxy.cn,direct
export GOPATH=~/go            # 视实际情况而定
export GOROOT=~/golang-1.18.3 # 视实际情况而定
export PATH=$GOROOT/bin:~/go/bin:$PATH

安装其它工具

!!! 不要在 datakit 代码目录安装这些工具/依赖,不然会触发包拉取不到的问题。

  • make: apt-get install make
  • gcc: apt-get install gcc
  • gcc-multilib: apt-get install -y gcc-multilib
  • tree: apt-get install tree
  • packr2: go install github.com/gobuffalo/packr/v2/packr2@v2.8.3
  • goyacc: go get golang.org/x/tools/cmd/goyacc
  • lint 相关
  • lint: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.42.1
  • eBPF 相关(eBPF 不是编译 DataKit 本身必须的,如果不安装它们,只会导致 eBPF 部分编译失败)
    • clang 10.0+: apt-get install clang
    • llvm 10.0+: apt-get install llvm
    • kernel headers: apt-get install -y linux-headers-$(uname -r)
  • 文档相关: waque 1.13.1+
  • 文档工具也不是必须的,可不安装

编译

  1. 拉取代码:上面这些依赖装好之后,再拉取代码不迟。
$ mkdir -p $GOPATH/src/gitlab.jiagouyun.com/cloudcare-tools
$ cd $GOPATH/src/gitlab.jiagouyun.com/cloudcare-tools

$ git clone https://github.com/GuanceCloud/datakit.git   # 可能被墙
$ git clone https://jihulab.com/guance-cloud/datakit.git # 国内极狐分站

$ cd datakit
  1. 编译:
make

如果编译通过,将在当前目录的 dist 目录下生成如下文件:

dist
├── [4.0K]  datakit-linux-amd64
│   ├── [ 72M]  datakit
│   └── [4.0K]  externals
│       ├── [ 14M]  logfwd
│       └── [10.0M]  oracle
├── [4.0K]  local
│   ├── [ 26M]  installer-linux-amd64
│   └── [ 228]  version
└── [4.0K]  standalone
    └── [4.0K]  datakit-ebpf-linux-amd64
                └── [ 38M]  datakit-ebpf

如果要编译全平台版本,执行:

make testing

DataKit 基本使用

可通过如下命令查看更多使用方法:

datakit help

如何贡献代码

在为我们贡献代码之前:

文档

License

FOSSA Status

Extension points exported contracts — how you extend this code

Node (Interface)
Node. [32 implementers]
internal/io/parser/ast.go
Dashboard (Interface)
Dashboard used to export inputs dashboard JSON. [70 implementers]
internal/plugins/inputs/inputs.go
Election (Interface)
(no doc) [90 implementers]
internal/election/election.go
AfterGatherHandler (Interface)
(no doc) [90 implementers]
internal/trace/aftergather.go
Filter (Interface)
(no doc) [6 implementers]
internal/filter/filter.go
InputWithVarbMapR (Interface)
(no doc) [8 implementers]
internal/pipeline/ptinput/point.go
Logger (Interface)
Logger ... [1 implementers]
internal/obfuscate/config.go
DatakitsGetter (Interface)
DatakitsGetter has a method to return a DatakitInterface. A group's client should implement this interface. [1 implementers]
internal/kubernetes/typed/guance/v1beta1/datakit.go

Core symbols most depended-on inside this repo

Errorf
called by 2234
internal/obfuscate/config.go
Error
called by 817
internal/plugins/inputs/wmi/core.go
Debugf
called by 563
internal/obfuscate/config.go
NewTagInfo
called by 480
internal/plugins/inputs/measurement.go
String
called by 459
internal/io/parser/ast.go
Run
called by 377
internal/plugins/inputs/inputs.go
Close
called by 348
internal/plugins/inputs/mysql/rows.go
Wait
called by 313
internal/goroutine/goroutine.go

Shape

Method 3,986
Function 3,480
Struct 1,323
Class 150
TypeAlias 129
Interface 79
FuncType 72
Enum 7

Languages

Go96%
C++2%
C1%
Python1%

Modules by API surface

internal/io/parser/ast.go160 symbols
internal/plugins/inputs/zipkin/compiled/thrift-0.16.0/zipkincore/core.go103 symbols
internal/plugins/inputs/mongodb/mongodbstats.go83 symbols
internal/plugins/inputs/jolokia.go61 symbols
internal/plugins/inputs/inputs.go57 symbols
internal/plugins/inputs/postgresql/input.go55 symbols
internal/plugins/inputs/container/k8s_client.go50 symbols
internal/pipeline/ptinput/point.go50 symbols
internal/plugins/inputs/rum/utils.go49 symbols
internal/plugins/inputs/influxdb/manual.go47 symbols
internal/plugins/inputs/snmp/input.go46 symbols
internal/plugins/inputs/kafka/metric.go45 symbols

Datastores touched

chunksCollection · 1 repos
(mongodb)Database · 1 repos
adminDatabase · 1 repos
configDatabase · 1 repos
localDatabase · 1 repos
(mysql)Database · 1 repos
mydbDatabase · 1 repos
otherdbDatabase · 1 repos

For agents

$ claude mcp add datakit \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page