赞
踩
到现在我们已经创建好了Prometheus监控,虽然prometheus中也有图表展示,但是我们更推荐使用Grafana来进行数据展示,以及监控触发阈值、触发报警之后,通过什么方式来实现报警。
点击Status
下面的Rules
菜单,即可查看Prometheus
的监控项;
那么如果我们想修改Prometheus
监控项的话怎么办呢?如何进行修改,配置文件在哪里呢?
[root@node1 ~]# cd prometheus-operator/templates/prometheus/rules
[root@node1 rules]# ls
alertmanager.rules.yaml kube-apiserver.rules.yaml kubernetes-apps.yaml kube-scheduler.rules.yaml prometheus-operator.yaml
etcd.yaml kube-prometheus-node-alerting.rules.yaml kubernetes-resources.yaml node-network.yaml prometheus.rules.yaml
general.rules.yaml kube-prometheus-node-recording.rules.yaml kubernetes-storage.yaml node.rules.yaml
k8s.rules.yaml kubernetes-absent.yaml kubernetes-system.yaml node-time.yaml
[root@node1 rules]#
上面的目录中显示的就是prometheus
默认的监控项目,想修改的话直接在此修改即可,修改完毕之后使用如下命令进行重新加载即可;
# 比如我们修改了etcd的监控项,也就是修改了etcd.yaml的配置文件,使用如下命令更新即可
[root@node1 ~]# pwd
/root
[root@node1 ~]# helm upgrade monitor ./prometheus-operator/ -f ./prometheus-operator/templates/prometheus/rules/etcd.yaml
也可以直接查看prometheus
有多少监控规则;
[root@node1 ~]# kubectl get PrometheusRule NAME AGE monitor-prometheus-operato-alertmanager.rules 17h monitor-prometheus-operato-etcd 17h monitor-prometheus-operato-general.rules 17h monitor-prometheus-operato-k8s.rules 17h monitor-prometheus-operato-kube-apiserver-availability.rules 17h monitor-prometheus-operato-kube-apiserver-slos 17h monitor-prometheus-operato-kube-apiserver.rules 17h monitor-prometheus-operato-kube-prometheus-general.rules 17h monitor-prometheus-operato-kube-prometheus-node-recording.rules 17h monitor-prometheus-operato-kube-scheduler.rules 17h monitor-prometheus-operato-kube-state-metrics 17h monitor-prometheus-operato-kubelet.rules 17h monitor-prometheus-operato-kubernetes-apps 17h monitor-prometheus-operato-kubernetes-resources 17h monitor-prometheus-operato-kubernetes-storage 17h monitor-prometheus-operato-kubernetes-system 17h monitor-prometheus-operato-kubernetes-system-apiserver 17h monitor-prometheus-operato-kubernetes-system-controller-manager 17h monitor-prometheus-operato-kubernetes-system-kubelet 17h monitor-prometheus-operato-kubernetes-system-scheduler 17h monitor-prometheus-operato-node-exporter 17h monitor-prometheus-operato-node-exporter.rules 17h monitor-prometheus-operato-node-network 17h monitor-prometheus-operato-node.rules 17h monitor-prometheus-operato-prometheus 17h monitor-prometheus-operato-prometheus-operator 17h [root@node1 ~]#
点击Alerts
即可查看,绿色表示正常状态,黄色表示等待报警状态,红色表示已经触发报警的状态,如下图;
我们这里也使用ingress-nginx的方式来访问,那么就需要创建一下,看看如何配置吧。
PS:如果说最后监控显示有问题,请确认是否是最新版,有的老版本的k8s和新版本的差距还是挺大的,不兼容的可能性颇大。
[root@node1 ~]# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE alertmanager-operated ClusterIP None <none> 9093/TCP,9094/TCP,9094/UDP 17h kubernetes ClusterIP 10.233.0.1 <none> 443/TCP 8d monitor-grafana ClusterIP 10.233.149.179 <none> 80/TCP 17h monitor-kube-state-metrics ClusterIP 10.233.141.38 <none> 8080/TCP 17h monitor-prometheus-node-exporter ClusterIP 10.233.128.202 <none> 9100/TCP 17h monitor-prometheus-operato-alertmanager ClusterIP 10.233.4.203 <none> 9093/TCP 17h monitor-prometheus-operato-operator ClusterIP 10.233.59.244 <none> 8080/TCP,443/TCP 17h monitor-prometheus-operato-prometheus ClusterIP 10.233.180.46 <none> 9090/TCP 17h prometheus-operated ClusterIP None <none> 9090/TCP 17h springboot-web-demo ClusterIP 10.233.16.229 <none> 80/TCP 7d19h springboot-web-svc ClusterIP None <none> 80/TCP 8d [root@node1 ~]# kubectl get svc monitor-grafana -o yaml apiVersion: v1 kind: Service metadata: # ---省略部分信息--- # ---省略部分信息--- time: "2022-05-04T16:55:04Z" name: monitor-grafana namespace: default resourceVersion: "825149" selfLink: /api/v1/namespaces/default/services/monitor-grafana uid: 4bf86224-644b-4f3a-9ff6-6d082fdebb5e spec: clusterIP: 10.233.149.179 # ---省略部分信息--- # ---省略部分信息--- [root@node1 ~]#
从上面可以看到grafana
的服务名字是monitor-grafana
;
[root@node1 ~]# cd namespace/prometheus/ [root@node1 prometheus]# [root@node1 prometheus]# vim ingress-grafana.yaml apiVersion: extensions/v1beta1 kind: Ingress metadata: name: grafana spec: rules: - host: grafana.yunweijia.com http: paths: - backend: serviceName: monitor-grafana servicePort: 80 path: / [root@node1 prometheus]# [root@node1 prometheus]# kubectl apply -f ingress-grafana.yaml ingress.extensions/grafana created [root@node1 prometheus]#
hosts
文件修改Windows
的hosts
文件,添加如下内容;
192.168.112.131 grafana.yunweijia.com
访问如下地址;
http://grafana.yunweijia.com
然后显示如下界面;
grafana
的用户名密码可以看到
Grafana
登录的时候有一个用户名密码,我们看看k8s
中的Grafana
默认的用户名密码是多少,如何查看;
查看charts
中的配置文件;
[root@node1 ~]# cd prometheus-operator/charts/grafana/
[root@node1 grafana]# vim values.yaml
adminUser: admin
# adminPassword: strongpassword
# Use an existing secret for the admin user.
admin:
existingSecret: ""
userKey: admin-user
passwordKey: admin-password
[root@node1 grafana]#
可以看到他读取的是一个已经存在的secret
,那么我们就去看下;
剩余内容请转至VX公众号 “运维家” ,回复 “161” 查看。
------ 以下内容为防伪内容,忽略即可 ------
------ 以下内容为防伪内容,忽略即可 ------
------ 以下内容为防伪内容,忽略即可 ------
warlinux解压,linux教程百度网盘,linux无法运行程序,linux移动指令,linux的主要版本,linux宝塔网页浏览器,linux怎么打开.d,linux应用安装空间不足,linux下复制备份吗,linux查看需要的依赖库,linux中htons,linux远程机器,nas与linux系统,linux下鼠标左键消息,修改linux绝对路径,linux服务器部署项目步骤,linux二进制文件存放目录,linux给一个文件做备份,linux移除空文件夹,linux输出文件到日志文件。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。