helm 安装 prometheus loki grafana

前言

我有个应用 需要接入一下指标跟日志收集,就采用k8s安装了 prometheus loki grafana

安装prometheus跟grafana

这个就比较简单,直接使用bitnami的charts就行

这里感谢一下大佬,谢谢大佬的镜像仓库,很好用! 大佬地址

配置文件如下:

bash 复制代码
# prometheus-values.yml
global:
  imageRegistry: "dockerpull.org"
server:
#我这里使用clusterIP的原因是因为我有traefik作为网关代理
  service:
    type: ClusterIP
alertmanager:
  service:
    type: ClusterIP      
bash 复制代码
# grafana-values.yml
global:
  imageRegistry: "dockerpull.org"
admin:
  password: "yourPassword"
persistence:
  enabled: false

安装

bash 复制代码
helm install -f prometheus-values.yml prometheus bitnami/prometheus -n monitor
helm install -f grafana-values.yml grafana bitnami/grafana -n monitor

装完了之后,使用traefik配置一下两个的域名,也就是配一下ingressRoute

bash 复制代码
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: grafana-web--com-tls
  namespace: monitor  
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`grafana.xxx.com`)
    kind: Rule
    services:
    - name: grafana
      port: 3000
bash 复制代码
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: prometheus-web-com-tls
  namespace: monitor  
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`prometheus.xxx.com`)
    kind: Rule
    services:
    - name: prometheus-server
      port: 80

在grafana里面配置一下数据源

安装loki

这里为什么要把loki单独拿出来讲呢,因为bitnami没有,至少截止至2024/12/04是没有的

这里我就只能使用官方的chart了 也就是 grafana/loki 但是呢 官方的chart配置太臃肿了,我们想定制也很麻烦,比如service的type, persitence 的 storageclass或者 resource-size,还有官方的 golbal.image.registry居然不生效,我没那么多时间去单独写一个chart了,我只能在官方的chart的values.yml文件上改了,我改了拉取镜像的registry以及storage

文件如下 下载

安装

bash 复制代码
helm install -f loki-values.yml loki grafana/loki -n monitor

对接grafana

chart安装成功后 console会打印如下注释

bash 复制代码
***********************************************************************
Connecting Grafana to Loki
***********************************************************************

If Grafana operates within the cluster, you'll set up a new Loki datasource by utilizing the following URL:

http://loki-gateway.monitor.svc.cluster.local/

***********************************************************************
Multi-tenancy
***********************************************************************

Loki is configured with auth enabled (multi-tenancy) and expects tenant headers (`X-Scope-OrgID`) to be set for all API calls.

You must configure Grafana's Loki datasource using the `HTTP Headers` section with the `X-Scope-OrgID` to target a specific tenant.
For each tenant, you can create a different datasource.

The agent of your choice must also be configured to propagate this header.
For example, when using Promtail you can use the `tenant` stage. https://grafana.com/docs/loki/latest/send-data/promtail/stages/tenant/

When not provided with the `X-Scope-OrgID` while auth is enabled, Loki will reject reads and writes with a 404 status code `no org id`.

You can also use a reverse proxy, to automatically add the `X-Scope-OrgID` header as suggested by https://grafana.com/docs/loki/latest/operations/authentication/

For more information, read our documentation about multi-tenancy: https://grafana.com/docs/loki/latest/operations/multi-tenancy/

按照文档操作即可

我这里的url 是 http://loki-gateway ,跟文档不一样的原因是 我的grafana跟loki在同一个 namespace,可以省略 .svc.cluster.local

相关推荐
张忠琳18 小时前
【client-go v0.36.1】(store Part 3)Store 超深度分析 — 集成模式、完整数据流、不变量、与 DeltaFIFO 协作
云原生·kubernetes·informer·store·client-go
赵渝强老师21 小时前
【赵渝强老师】Kubernetes(K8s)中的金丝雀升级
linux·docker·云原生·容器·kubernetes
鹤落晴春21 小时前
【K8s】配置存储卷
云原生·容器·kubernetes
张忠琳1 天前
【client-go v0.36.1】(DeltaFIFO Part 1)DeltaFIFO 超深度分析 — 模块定位、类结构、接口层次、构造与初始化
云原生·kubernetes·deltafifo·informer·client-go
ba_pi1 天前
k8s删除pod
linux·容器·kubernetes
张忠琳1 天前
【client-go v0.36.1】tools/cache 深度分析(下篇)— RealFIFO 深度、集成架构、生命周期、设计模式总结
云原生·kubernetes·cache·informer·client-go
张忠琳1 天前
【client-go v0.36.1】(store Part 2)Store 超深度分析 — threadSafeMap 核心、索引体系、RV追踪、事务机制
云原生·kubernetes·informer·store·client-go
sbjdhjd1 天前
04(上)| k8s中的微服务
微服务·云原生·kubernetes·开源·云计算·excel·kubelet
qq_452396231 天前
第二篇:《K8s 集群搭建:Minikube、kubeadm、Kind 对比与实操》
容器·kubernetes·kind
小哈里1 天前
【K8S】OCI标准下的企业级镜像治理:Harbor+Skopeo+Trivy 最佳实践
云原生·容器·kubernetes·harbor·镜像·skopen