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

相关推荐
deeper_wind3 小时前
k8s-单主机Master集群部署+单个pod部署lnmp论坛服务(小白的“升级打怪”成长之路)
云原生·容器·kubernetes
zhenshanrenhao5 小时前
#买硬盘欲安装k8s记
云原生·容器·kubernetes
tb_first7 小时前
k8sday09
linux·云原生·容器·kubernetes
稚辉君.MCA_P8_Java8 小时前
豆包 Java的23种设计模式
java·linux·jvm·设计模式·kubernetes
40kuai1 天前
kubernetes中数据存储etcd
容器·kubernetes·etcd
Harvey_D1 天前
【部署K8S集群】 1、安装前环境准备配置
云原生·容器·kubernetes
Wezzer1 天前
k8s单master部署
云原生·容器·kubernetes
ModelWhale1 天前
“大模型”技术专栏 | 浅谈基于 Kubernetes 的 LLM 分布式推理框架架构:概览
分布式·kubernetes·大模型
SirLancelot12 天前
K8s-kubernetes(二)资源限制-详细介绍
微服务·云原生·容器·kubernetes·k8s·devops·kubelet
夜莺云原生监控2 天前
Prometheus 监控 Kubernetes Cluster 最新极简教程
容器·kubernetes·prometheus