绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
prometheus 数据传输到远程 VictoriaMetrics 存储
2022-05-13 16:38:19

查看prometheus

kubectl get prometheus k8s -n kubesphere-monitoring-system -o yaml

 

添加  http://172.31.115.19:8480/insert/0/prometheus/api/v1/write , 使prometheus 数据传输到远程 VictoriaMetrics 存储

没法设置不存到本地的tsdb。如果实在不想的话,可以设置本地存储的保留时间为1个小时。
prome 在本地获取不到的时候再去远程读取数据。
但是实际的场景下,我们这边本地存储是保留时间是1天,因为prometheus的远程读的效率并没有本地读的高,其实整个监控的本质,都是频繁读取近的数据,越是历史数据被读取的少。这样做对远程存储介质也好。 

 

添加使用victoriaMetrics  读写接口 和 保存1天

 

复制代码
[root@master1 ~]# kubectl get prometheus k8s -n kubesphere-monitoring-system -o yaml | grep retention
      {"apiVersion":"monitoring.coreos.com/v1","kind":"Prometheus","metadata":{"annotations":{},"name":"k8s","namespace":"kubesphere-monitoring-system"},"spec":{"additionalScrapeConfigs":{"key":"prometheus-additional.yaml","name":"additional-scrape-configs"},"affinity":{"nodeAffinity":{"preferredDuringSchedulingIgnoredDuringExecution":[{"preference":{"matchExpressions":[{"key":"node-role.kubernetes.io/monitoring","operator":"Exists"}]},"weight":100}]},"podAntiAffinity":{"preferredDuringSchedulingIgnoredDuringExecution":[{"podAffinityTerm":{"labelSelector":{"matchExpressions":[{"key":"prometheus","operator":"In","values":["k8s"]}]},"namespaces":["kubesphere-monitoring-system"],"topologyKey":"kubernetes.io/hostname"},"weight":100}]}},"alerting":{"alertmanagers":[{"name":"alertmanager-main","namespace":"kubesphere-monitoring-system","port":"web"}]},"image":"192.168.15.198/prom/prometheus:v2.20.1","nodeSelector":{"kubernetes.io/os":"linux"},"podMonitorNamespaceSelector":{},"podMonitorSelector":{},"query":{"maxConcurrency":1000},"remoteWrite":[{"url":"http://172.31.115.19:8480/insert/0/prometheus/api/v1/write"}],"replicas":2,"resources":{"limits":{"cpu":"4","memory":"16Gi"},"requests":{"cpu":"200m","memory":"400Mi"}},"retention":"7d","ruleSelector":{"matchLabels":{"prometheus":"k8s","role":"alert-rules"}},"scrapeInterval":"1m","securityContext":{"fsGroup":,"runAsNonRoot":false,"runAsUser":},"serviceAccountName":"prometheus-k8s","serviceMonitorNamespaceSelector":{},"serviceMonitorSelector":{},"storage":{"volumeClaimTemplate":{"spec":{"resources":{"requests":{"storage":"20Gi"}},"storageClassName":"nfs-storage"}}},"tolerations":[{"effect":"NoSchedule","key":"dedicated","operator":"Equal","value":"monitoring"}],"version":"v2.20.1"}}
        f:retention: {}
  retention: 7d
[root@master1 ~]# kubectl get prometheus k8s -n kubesphere-monitoring-system -o yaml 
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
  name: k8s
  namespace: kubesphere-monitoring-system
spec:
  additionalScrapeConfigs:
    key: prometheus-additional.yaml
    name: additional-scrape-configs
  affinity:
    nodeAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - preference:
          matchExpressions:
          - key: node-role.kubernetes.io/monitoring
            operator: Exists
        weight: 100
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - podAffinityTerm:
          labelSelector:
            matchExpressions:
            - key: prometheus
              operator: In
              values:
              - k8s
          namespaces:
          - kubesphere-monitoring-system
          topologyKey: kubernetes.io/hostname
        weight: 100
  alerting:
    alertmanagers:
    - name: alertmanager-main
      namespace: kubesphere-monitoring-system
      port: web
  image: 192.168.15.198/prom/prometheus:v2.20.1
  nodeSelector:
    kubernetes.io/os: linux
  podMonitorNamespaceSelector: {}
  podMonitorSelector: {}
  query:
    maxConcurrency: 1000
  remoteRead:
  - url: http://172.31.115.19:8480/select/0/prometheus
  remoteWrite:
  - url: http://172.31.115.19:8480/insert/0/prometheus/api/v1/write
  replicas: 2
  resources:
    limits:
      cpu: "4"
      memory: 16Gi
    requests:
      cpu: 200m
      memory: 400Mi
  retention: 1d
  ruleSelector:
    matchLabels:
      prometheus: k8s
      role: alert-rules
  scrapeInterval: 1m
  securityContext:
    fsGroup: 
    runAsNonRoot: false
    runAsUser: 
  serviceAccountName: prometheus-k8s
  serviceMonitorNamespaceSelector: {}
  serviceMonitorSelector: {}
  storage:
    volumeClaimTemplate:
      spec:
        resources:
          requests:
            storage: 20Gi
        storageClassName: nfs-storage
  tolerations:
  - effect: NoSchedule
    key: dedicated
    operator: Equal
    value: monitoring
  version: v2.20.1
复制代码

 来源 https://www.cnblogs.com/fengjian2016/p/15855451.html

分享好友

分享这个小栈给你的朋友们,一起进步吧。

VictoriaMetrics
创建时间:2022-03-21 14:44:18
VictoriaMetrics
展开
订阅须知

• 所有用户可根据关注领域订阅专区或所有专区

• 付费订阅:虚拟交易,一经交易不退款;若特殊情况,可3日内客服咨询

• 专区发布评论属默认订阅所评论专区(除付费小栈外)

技术专家

查看更多
  • itt0918
    专家
戳我,来吐槽~