# Clickvisual Agent 用法

ClickVisual 提供了LogAgent接口,用于直接查询K8S Node节点中的日志数据

# Clickvisual Agent 接口查询日志流程

  • 提供一个Search接口
  • 根据Search参数获得需要查询的数据
  • 根据namespace,container,获取到要查container的日志目录
  • 根据日志条件,扫描日志内容
  • 返回数据

# Clickvisual Agent 部署方式

使用Daemonset部署到K8S Node节点上

# Containerd 权限

需要挂载3个目录,待确认,估计目前只需要containerd权限

  • /var/run 读权限
  • /var/log 读权限
  • /var/lib/containerd 读权限
apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    name: clickvisual-agent
  name: clickvisual-agent
  namespace: default
spec:
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      k8s-app: clickvisual-agent
    spec:
      affinity: {}
      containers:
        - command:
            - /bin/sh
            - '-c'
            - /clickvisual/bin/clickvisual agent
          env:
            - name: EGO_LOG_WRITER
              value: stderr
            - name: EGO_CONFIG_PATH
              value: /data/config/dev.toml
          image: xxxx/clickvisual:84674b6
          imagePullPolicy: Always
          name: clickvisual-agent
          resources:
            limits:
              cpu: '1'
              memory: 1Gi
            requests:
              cpu: 100m
              memory: 128Mi
          volumeMounts:
            - mountPath: /var/run
              name: run
              readOnly: true
            - mountPath: /var/log
              name: log
              readOnly: true
            - mountPath: /var/lib/containerd
              name: containerd-log
              readOnly: true
            - mountPath: /data/config
              name: config-volume-clickvisual
      dnsPolicy: ClusterFirstWithHostNet
      hostNetwork: true
      imagePullSecrets:
        - name: ee
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      serviceAccount: xx
      serviceAccountName: xx
      terminationGracePeriodSeconds: 30
      tolerations:
        - operator: Exists
      volumes:
        - hostPath:
            path: /var/run
            type: Directory
          name: run
        - hostPath:
            path: /var/log
            type: Directory
          name: log
        - hostPath:
            path: /var/lib/containerd
            type: Directory
          name: containerd-log
        - name: config-volume-clickvisual
          projected:
            defaultMode: 420
            sources:
              - configMap:
                  name: clickvisual
  updateStrategy:
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
    type: RollingUpdate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82

# Get Query参数

  • startTime: 开始时间
  • endTime: 结束时间
  • data: 查询时间: last 6h, yesterday, today
  • limit: 查询条数
  • namespace: 查询哪个命令空间
  • isK8s: 是否k8s,0或1
  • container: k8s状态下要查的容器名,数组
  • timestampKey: 时间字段名称,默认ts
  • timestampFormat: 时间格式,默认unix时间戳

# 使用命令行工具

# 使用命令行查询
./bin/clickvisual command --config=config/dev.toml --k8s=true --key="lv=error" --container=svc-auth
# 使用命令行上传某个服务器上的文本
./bin/clickvisual upload --config=config/dev.toml --pathName="/var/log/pods/xxxx/logtail/9.log"
1
2
3
4
上次更新: 2024-02-13 12:35:52