从零到一:GreptimeDB 与 Grafana 的无缝集成指南

开发 前端 其他数据库
我想着怎么给 GreptimeDB 弄一个自定义的存储,因为它的这个 控制器 创建完成后,就会自动创建 PV 和 PVC 然后挂载,10G 的存储,但是我想要自定义,如下 YAML。

引言

我们的上一篇文章中讲解到了 Prometheus-Agent + GreptimeDB,当时最大的问题是使用 GreptimeDB 作为 Grafana 的数据源,然后去看 Dashboard 有很多的都没有数据,如下图所示

图片图片

当时文章一经发出,就收到了来自 GreptimeDB[1] 官方人员的注意,随后,我们经过进一步的交流,如下图所示

图片图片

图片图片

随后,我们进入群聊

图片图片

图片图片

以下的这部分算是 get 到了终点,但是当时并没有立刻采取行动

图片图片

图片图片

图片图片

图片图片

图片图片

到了后面,我想着怎么给 GreptimeDB 弄一个自定义的存储,因为它的这个 控制器 创建完成后,就会自动创建 PV 和 PVC 然后挂载,10G 的存储,但是我想要自定义,如下 YAML。

apiVersion: greptime.io/v1alpha1
kind: GreptimeDBStandalone
metadata:
  name: greptimedb
  namespace: greptimedb-admin
spec:
  base:
    main:
      image: greptime/greptimedb:v0.11.2
     # resources:
     #   limits:
     #     cpu: "1"       # 最大可使用的 2 个 CPU
     #     memory: "1Gi"  # 最大可使用 4GB 内存
     #   requests:
     #     cpu: "1"       # 最少需要 1 个 CPU
     #     memory: "1Gi"  # 最少需要 2GB 内存
  datanodeStorage:   # 我这里没有定义 StorageClassName 是因为它会去使用 default 的
    fs:
      mountPath: "/data/greptimedb"
      name: "greptimedb-storage"
      storageRetainPolicy: "Retain" # 数据卷策略
      storageSize: "30Gi"

然后我们部署看看;

jacobleo@Jacobs-MacBook-Air greptimedb % kg pvc -A
NAMESPACE          NAME                                         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   VOLUMEATTRIBUTESCLASS   AGE
greptimedb-admin   greptimedb-storage-greptimedb-standalone-0   Bound    pvc-160dd148-b272-439f-b8e1-f480def01bfc   30Gi       RWO            local-path     <unset>                 36s
monitoring         grafana-pvc                                  Bound    pvc-5cd3dc87-bda9-45aa-b02c-f54112b49a2b   30Gi       RWO            local-path     <unset>                 5h3m
monitoring         prometheus-k8s-db-prometheus-k8s-0           Bound    pvc-e6daef05-4ff1-42bf-b4f0-2b459d3a6f12   1Gi        RWO            local-path     <unset>                 5h2m
monitoring         prometheus-k8s-db-prometheus-k8s-1           Bound    pvc-e294d11d-4099-4ba8-ade8-24eed34f79de   1Gi        RWO            local-path     <unset>                 5h2m

可以看到是 30G,并没有我们上面说的那个问题,原来是我搞错了,我们下面这个关于存储的问题就解决了。

图片图片

图片图片

这边当时也挺搞笑的,哈哈!

图片图片

图片图片

图片图片

图片图片

图片图片

图片图片

图片图片

图片图片

图片图片

图片图片

图片图片

我们这里添加下:

这里添加就 work 了,然后如果还有更多的,就继续添加就可以了。

·····
  externalLabels:
    cluster: "cluster-test"
·····

图片图片

可以看到,终于有数据了。

图片图片

但是这又有一个问题,其实还有很多像这样类似的问题,大致解决,和上面的是一样的思路。

图片图片

我们添加下就可以了。

·····
  externalLabels:
    cluster: "cluster-test"
    workload_type: "deployment, stateful"
·····

弄了半天,还是不行,在此希望有大佬出主意,非常感谢,作为回报,我会把你记在心里!

可以看下我们最终的 YAML 文件;

apiVersion: v1
kind: ServiceAccount
metadata:
  name: prometheus-agent
  namespace: greptimedb-admin
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: prometheus-agent
rules:
  - apiGroups: [""]
    resources:
      - namespaces
      - secrets
      - persistentvolumeclaims
    verbs: ["get", "list", "watch"]
  - apiGroups: ["monitoring.coreos.com"]
    resources: ["servicemonitors", "podmonitors", "prometheuses"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources:
      - nodes
      - nodes/metrics
      - services
      - endpoints
      - pods
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources:
      - configmaps
    verbs: ["get"]
  - apiGroups:
      - discovery.k8s.io
    resources:
      - endpointslices
    verbs: ["get", "list", "watch"]
  - apiGroups:
      - networking.k8s.io
    resources:
      - ingresses
    verbs: ["get", "list", "watch"]
  - nonResourceURLs: ["/metrics"]
    verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: prometheus-agent
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: prometheus-agent
subjects:
  - kind: ServiceAccount
    name: prometheus-agent
    namespace: greptimedb-admin
---
apiVersion: monitoring.coreos.com/v1alpha1
kind: PrometheusAgent
metadata:
  name: prometheus-agent
  namespace: greptimedb-admin
spec:
  image: quay.io/prometheus/prometheus:v3.0.1
  replicas: 1
  serviceAccountName: prometheus-agent
  enableFeatures: 
    - agent
  remoteWrite:
    - url: "http://greptimedb.kubernetes.click/v1/prometheus/write?db=public"
      queueConfig:
        capacity: 5000
        maxSamplesPerSend: 10000
        batchSendDeadline: 5s
  serviceMonitorSelector: {}
  serviceMonitorNamespaceSelector: {}
  podMonitorNamespaceSelector: {}
  podMonitorSelector: {}
  resources:
    limits:
      cpu: "2"
      memory: "4Gi"
    requests:
      cpu: "1"
      memory: "2Gi"
  externalLabels:
    cluster: "cluster-test"
    workload_type: "deployment, stateful"

结语

这个问题,还可以,不算是特别过分吧,还是跌亏有 GreptimeDB 的相关人员,不然,这个问题怎么解决?

那么我们的 Prometheus-Agent + GreptimeDB 算是不是很圆满地结束了,但是后面大概还会又些小问题,不过都是小事了。

引用链接

[1] GreptimeDB: https://greptime.com/

责任编辑:武晓燕 来源: 云原生运维圈
相关推荐

2021-10-28 07:10:21

rollupPlugin插件编写

2020-09-08 18:37:49

TypeScript开发前端

2023-11-17 12:11:26

GORMGo Web

2021-07-12 07:33:31

Nacos微服务管理

2023-04-06 08:01:30

RustMutex

2024-11-25 09:10:03

2023-12-08 09:00:00

2023-08-01 09:00:00

高并发性能优化

2024-02-26 07:31:26

WindowsLinuxmacOS

2013-12-18 13:30:19

Linux运维Linux学习Linux入门

2021-08-07 21:51:17

服务器网站部署

2023-01-12 22:00:48

2024-04-26 08:17:09

GoGoogle项目

2013-11-26 17:38:03

ArrayFusionCube

2024-06-12 09:06:48

2021-06-30 07:51:09

新项目领域建模

2022-02-13 23:00:48

前端微前端qiankun

2023-12-28 08:16:32

Spring容器管理

2024-07-03 10:09:29

2020-07-17 17:17:16

Kubernetes宕机Spring Clou
点赞
收藏

51CTO技术栈公众号