当前位置: 首页 > news >正文

关于公司网站建设的请示网站建设面试对策

关于公司网站建设的请示,网站建设面试对策,公众出行服务网站建设,制作网站软件网站一、Prometheus介绍 Prometheus是一个开源系统监控和警报工具包#xff0c;最初在 SoundCloud构建。自 2012 年成立以来#xff0c;许多公司和组织都采用了 Prometheus#xff0c;该项目拥有非常活跃的开发者和用户社区。它现在是一个独立的开源项目#xff0c;独立于任何… 一、Prometheus介绍 Prometheus是一个开源系统监控和警报工具包最初在 SoundCloud构建。自 2012 年成立以来许多公司和组织都采用了 Prometheus该项目拥有非常活跃的开发者和用户社区。它现在是一个独立的开源项目独立于任何公司维护。为了强调这一点并明确项目的治理结构Prometheus 于 2016 年加入 云原生计算基金会成为继Kubernetes之后的第二个托管项目。 Prometheus 将其指标收集并存储为时间序列数据即指标信息与记录时的时间戳以及称为标签的可选键值对一起存储。 有关 Prometheus 的更详细概述请参阅 媒体部分链接的资源。 特点 普罗米修斯的主要特点是 具有由度量名称和键/值对标识的时间序列数据的多维数据模型PromQL一种 利用这种维度的灵活查询语言不依赖分布式存储单个服务器节点是自治的时间序列收集通过 HTTP 上的拉模型进行通过中间网关支持推送时间序列通过服务发现或静态配置发现目标多种图形模式和仪表板支持 架构图 二、搭建Prometheus监控体系 我这里提前准备了三台虚拟机 maste、node1、node2 1、Prometheus 服务端 master机 2、expot 客户端node1、node2 3、granfan 可视化展示Prometheus数据 1、搭建Prometheus服务端 1.1、下载并解压缩 #下载 wget https://github.com/prometheus/prometheus/releases/download/v3.4.0-rc.0/prometheus-3.4.0-rc.0.linux-amd64.tar.gz #解压到 /usr/local tar -xvf prometheus-2.54.0-rc.1.linux-amd64.tar.gz -C /data/ #查看版本号 cd /data/prometheus-2.54.0-rc.1.linux-amd64/ ./prometheus --version prometheus, version 2.54.0-rc.1 (branch: HEAD, revision: 6d7ed08850849c2adcedb63cddeb61fc4f6a425e)build user: root64a0056e2b2abuild date: 20240806-06:01:39go version: go1.22.5platform: linux/amd64tags: netgo,builtinassets,stringlabels1.2、Prometheus.yml配置解释 这里我们可以看到有四个模块 1、global 全局配置 2、 #1、global global:scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.# scrape_timeout is set to the global default (10s). 2、 1.3、设置systemctl启动 vim /usr/lib/systemd/system/prometheus.service [Unit] Descriptionhttps://prometheus.io[Service] ExecStart/usr/local/prometheus/prometheus --config.file/usr/local/prometheus/prometheus.yml # 启动地址[Install] WantedBymulti-user.target1.4、启动Prometheus #重载systemctl 配置 systemctl daemon-reload #设置开机自启 systemctl enable prometheus #启动服务 systemctl start prometheus 1.5、查看是否启动 systemctl status Prometheus 1.6、浏览器访问 #开设9090端口号 iptables -I INPUT -p tcp -dport 9090 -j ACCEPT #浏览器访问 http://172.16.254.190:9090 2、搭建客户端export 添加主句监控 2.1、下载、解压、并启动 切换到node1上 #切换到node1主机上 ssh node1 #下载 wget https://github.com/prometheus/node_exporter/releases/download/v-1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz #解压缩 tar -xfv node_exporter-1.8.2.linux-amd64.tar.gz -C /data 2.2、设置systemctl 启动 vim /usr/lib/systemd/system/node_exporter.service [Unit] DescriptionPrometheus-Server Afternetwork.target[Service] ExecStart/data/node_exporter-1.8.2.linux-amd64/node_exporter --web.listen-address:9500 Userroot[Install] WantedBymulti-user.target/data/node_exporter-1.8.2.linux-amd64/node_exporter --web.listen-address:9500 2.3、启动服务 #重载systemctl 配置 systemctl daemon-reload #设置开机自启 systemctl enable node_exporter #启动服务 systemctl start node_exporter 2.4、验证是否启动采集到数据 curl http://172.16.254.191:9100/metrics# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles. # TYPE go_gc_duration_seconds summary go_gc_duration_seconds{quantile0} 0 go_gc_duration_seconds{quantile0.25} 0 go_gc_duration_seconds{quantile0.5} 0node2主机上也是按照此步骤操作 2.5、修改Prometheus配置文件 - job_name: prometheus# metrics_path defaults to /metrics# scheme defaults to http.static_configs:- targets: [localhost:9090]- job_name: node1static_configs:- targets: [172.16.254.191:9500]labels:service: ops- job_name: node2static_configs:- targets: [172.16.254.192:9500]labels:service: ops#- targets 后服务器ip端口号 2.6、重新启动Prometheus systemctl restart prometheus 2.7、浏览器访问Prometheus http:192.168.19.135/9090 我们这里可以看到node1和node2主机已经监控到了 2.8、配置Prometheus规则 在该目录下添加rule规则 先打开Prometheus配置文件并删除rule注释 vim /data/prometheus-3.1.0.linux-amd64/prometheus.yml # Load rules once and periodically evaluate them according to the global evaluation_interval. rule_files:- first_rules.yml # - second_rules.ymlvim /data/prometheus-3.1.0.linux-amd64/first_rules.yml groups: - name: noderules:- alert: InstanceDownexpr: up{jobnode1} 0for: 15slabels:severity: criticalserver: opsannotations:description: {{ $labels.instance }} of job {{ $labels.job }} of service {{ $labels.service }} has been down for more than 30 seconds.summary: Instance {{ $labels.instance }} down 2.9、重启Prometheus服务 并点击statusrule   下方表示rule设置成功 3、granfan搭建 3.1、下载granfan并启动 yum install -y https://dl.grafana.com/enterprise/release/grafana-enterprise-12.0.2security~01-1.x86_64.rpmsystemctl start grafana 3.2、浏览器访问 #开设3000端口 iptables -I INPUT -p tcp --dport 3000 -j ACCEPT 浏览器访问 http://172.16.254.190:3000/ 初始用户和密码都为admin  admin  第一次会提示修改密码 3.2.1、添加Add data source 代表成功 3.2.2、导入仪表盘 添加模版id 11074 4、添加alertmanager报警 4.1下载altermanager并解压缩 在master主机上添加alertmanager wget https://github.com/prometheus/alertmanager/releases/download/v0.28.0/alertmanager-0.28.1.linux-amd64.tar.gz tar -xf alertmanager-0.28.0.linux-amd64.tar.gz -C /data 4.2、设置systemctl启动服务 vim /usr/lib/systemd/system/alertmanager.service [unit] DescriptionAlertmanager-Server Afternetwork.target[Service] ExecStart/data/alertmanager-0.28.0.linux-amd64/alertmanager --config.file/data/alertmanager-0.28.0.linux-amd64/alertmanager.yml Userroot[Install] WantedBymulti-user.target4.3、启动服务 #重新加载配置文件 systemctl daemon-reload #设置开机自启 systemctl enable alertmanager.service systemctl start alertmanager #查看进程是否启动 ps -ef|grep alertmanager root 1122 1 0 00:40 ? 00:00:00 /data/alertmanager-0.28.0.linux-amd64/alertmanager --config.file/data/alertmanager-0.28.0.linux-amd64/alertmanager.yml root 1145 27020 0 00:40 pts/3 00:00:00 grep --colorauto alertmanager4.4、可以用webhook.site测试一下是否能触发报警 webhook.site是一个用于测试转换和自动化web请求和电子邮件平台。他提供多种功能能创建自定义的webhook URL,接受和查看HTTP请求的详细信息以及执行自定义的操作。 1、打开链接(1) Webhook.site - Test, transform and automate Web requests and emails 2、打开alertmanager配置文件输入上面复制的url vim /data/alertmanager-0.28.0.linux-amd64/alertmanager.yml route:group_by: [alertname]group_wait: 30sgroup_interval: 5mrepeat_interval: 1hreceiver: web.hook receivers:- name: web.hookwebhook_configs:- url: https://webhook.site/a9cf0e68-6c0d-49ab-b553-cb9706a0ea70 inhibit_rules:- source_match:severity: criticaltarget_match:severity: warningequal: [alertname, dev, instance]3、这时我们登录node1主机关闭node_export 就会自动触发报警 #登录node1 ssh node1 #关闭node节点 systemctl stop node_exporter 代表Prometheusalertmanager成功搭建并建立连接。这时我们就可以使用钉钉告警通道触发报警了。 5、钉钉实现报警 5.1、需要下载 Webhook-dingtalk安装并启动 wegt https://github.com/timonwong/prometheus-webhook-dingtalk/releases/download/v2.1.0/prometheus-webhook-dingtalk-2.1.0.linux-amd64.tar.gz #解压 tar -xf prometheus-webhook-dingtalk-2.1.0.linux-amd64.tar.gz -C /datacd /data/prometheus-webhook-dingtalk-2.1.0.linux-amd64.tar.gz 5.2、添加systemctl管理 vim /usr/lib/systemd/system/webhook.service [Unit] DescriptionPrometheus-Server[Service] ExecStart/data/prometheus-webhook-dingtalk-2.1.0.linux-amd64/prometheus-webhook-dingtalk --config.file/data/prometheus-webhook-dingtalk-2.1.0.linux-amd64/config.example.yml[Install] WantedBymulti-user.target5.3、设置开机自启并启动服务 systemctl daemon-reload systemctl enable webhook systemctl start webhook 5.4、电脑下载钉钉软件 步骤一创建群聊添加机器人 步骤二、 步骤三、设置自定义 步骤四、 步骤五、设置加签 并复制 步骤六、 这时我们就看到钉钉添加机器人成功了 5.5、在webhook配置文件当中添加webhook1 vim /data/prometheus-webhook-dingtalk-2.1.0.linux-amd64/config.example.yml ## Request timeout # timeout: 5s## Uncomment following line in order to write template from scratch (be careful!) #no_builtin_template: true## Customizable templates path #templates: # - contrib/templates/legacy/template.tmpl## Targets, previously was known as profiles targets:webhook1: #步骤六的机器人地址url: https://oapi.dingtalk.com/robot/send?access_token62638c23119337210244fa5c33b5d0dd5a5df105b3d802538df09e33c45333d5# secret for signature 步骤五的安全设置的加密secret: SEC35f4c12c1997a68be9230c1cdc07bb6100fc8f456a685ba29b0039adaf445734webhook2:url: https://oapi.dingtalk.com/robot/send?access_tokenxxxxxxxxxxxxwebhook_legacy:url: https://oapi.dingtalk.com/robot/send?access_tokenxxxxxxxxxxxx# Customize template contentmessage:# Use legacy templatetitle: {{ template legacy.title . }}text: {{ template legacy.content . }}webhook_mention_all:url: https://oapi.dingtalk.com/robot/send?access_tokenxxxxxxxxxxxxmention:all: truewebhook_mention_users:url: https://oapi.dingtalk.com/robot/send?access_tokenxxxxxxxxxxxxmention:mobiles: [156xxxx8827, 189xxxx8325] 4.5、配置钉钉模版 vim /data/prometheus-webhook-dingtalk-2.1.0.linux-amd64/template.tmpl/template.tmpl{{ define __subject }} [{{ .Status | toUpper }}{{ if eq .Status firing }}:{{ .Alerts.Firing | len }}{{ end }}] {{ end }}{{ define __alert_list }}{{ range . }} --- {{ if .Labels.owner }}{{ .Labels.owner }}{{ end }}**告警主题**: {{ .Annotations.summary }}**告警类型**: {{ .Labels.alertname }}**告警级别**: {{ .Labels.severity }} **告警主机**: {{ .Labels.instance }} **告警信息**: {{ index .Annotations description }}**告警时间**: {{ dateInZone 2006.01.02 15:04:05 (.StartsAt) Asia/Shanghai }} {{ end }}{{ end }}{{ define __resolved_list }}{{ range . }} --- {{ if .Labels.owner }}{{ .Labels.owner }}{{ end }}**告警主题**: {{ .Annotations.summary }}**告警类型**: {{ .Labels.alertname }} **告警级别**: {{ .Labels.severity }}**告警主机**: {{ .Labels.instance }}**告警信息**: {{ index .Annotations description }}**告警时间**: {{ dateInZone 2006.01.02 15:04:05 (.StartsAt) Asia/Shanghai }}**恢复时间**: {{ dateInZone 2006.01.02 15:04:05 (.EndsAt) Asia/Shanghai }} {{ end }}{{ end }}{{ define default.title }} {{ template __subject . }} {{ end }}{{ define default.content }} {{ if gt (len .Alerts.Firing) 0 }} **侦测到{{ .Alerts.Firing | len }}个故障** {{ template __alert_list .Alerts.Firing }} --- {{ end }}{{ if gt (len .Alerts.Resolved) 0 }} **恢复{{ .Alerts.Resolved | len }}个故障** {{ template __resolved_list .Alerts.Resolved }} {{ end }} {{ end }}{{ define ding.link.title }}{{ template default.title . }}{{ end }} {{ define ding.link.content }}{{ template default.content . }}{{ end }} {{ template default.title . }} {{ template default.content . }} vim /data/prometheus-webhook-dingtalk-2.1.0.linux-amd64/config.example.yml ## Request timeout # timeout: 5s## Uncomment following line in order to write template from scratch (be careful!) #no_builtin_template: true## Customizable templates path #删掉注释模版文件 templates:- contrib/templates/legacy/template.tmpl5.6、配置alertmanager配置文件 route: #分组聚合减少告警消息数量group_by: [alertname] #告警时先收集报警然后在发送group_wait: 30s #当收到告警时先等待30秒在一起发送group_interval: 5m #发送警告时间间隔repeat_interval: 1h #重复报警时间间隔receiver: dingding.webhook1 receivers:- name: dingdingwebhook1webhook_configs:- url: http://172.16.254.190:8060/dingtalk/webhook1/send inhibit_rules:- source_match:severity: criticaltarget_match:severity: warningequal: [alertname, dev, instance]5.7、重启webhook和alertmanager服务 systemctl restart webhook systemctl restart alertmanager 6、查看是否能触发报警 6.1、登录node1服务器关闭node_exporte服务 systemctl restart alertmanager 三、生产环境场景 Nginx监控 nginx-module-vtsNginx virtual host traffic status moduleNginx的监控模块能够提供JSON格式的数据产出。 nginx-vts-exporterSimple server that scrapes Nginx vts stats and exports them via HTTP for Prometheus consumption。主要用于收集Nginx的监控数据并给Prometheus提供监控接口默认端口号9913。 Prometheus监控Nginx-vts-exporter提供的Nginx数据并存储在时序数据库中可以使用PromQL对时序数据进行查询和聚合。 Nginx安装 前期准备 1、Nginx源码获取 #创建源码包文件 mkdir /data/sourcewget https://nginx.org/download/nginx-1.28.0.tar.gztar -xf nginx-1.28.0.tar.gz -C /data/source/2、安装编译工具及依赖库脚本如下: yum -y install gcc pcre-devel zlib-devel openssl-devel libxml2-devel \libxslt-devel gd-devel GeoIP-devel jemalloc-devel libatomic_ops-devel \perl-devel perl-ExtUtils-Embed 3、编译配置参数配置 --prefixPATH/usr/local编译后代码的安装目录--with-select_module不编译编译 select I/O 事件机制模块在不支持 Nginx 默认 I/O 事件机制的操作系统下自动编译该模块--without-select_module编译不编译 select I/O 事件机制模块--with-poll_module不编译编译 poll/O 事件机制模块在不支持 Nginx 默认 I/O 事件机制的操作系统下自动编译该模块--without-poll_module编译不编译 poll I/O 事件机制模块--with-threads不编译 启用线程池支持--with-file-aio不编译启用 AIO 支持--with-http_ssl_module不编译编译 SSL 模块--with-http_v2_module不编译编译 HTTP/2 模块--with-http_realip_module不编译编译 HTTP 的真实 IP 模块--with-http_addition_module不编译编译响应内容追加模块--with-http_xslt_module不编译编译 XSLT 样式表转换模块--with-http_xslt_moduledynamic--动态编译 XSLT 样式表转换 XML 响应模块--with-http_image_filter_module编译编译图像转换模块--with-http_image_filter_moduledynamic--动态编译图像转换模块--with-http_geoip_module编译编译客户端 IP 解析城市地址模块--with-http_geoip_moduledynamic--动态编译客户端 IP 解析城市地址模块--with-http_sub_module不编译编译字符串替换模块--with-http_dav_module不编译编译 WebDAV 协议支持模块--with-http_flv_module不编译 编译 FLV 文件伪流媒体服务器支持模块--with-http_mp4_module不编译编译 MP4 文件伪流媒体服务器支持模块--with-http_gunzip_module不编译 编译 gzip 压缩兼容模块--with-http_gzip_static_module不编译   编译发送 gz 预压缩文件数据模块--with-http_auth_request_module不编译  编译请求认证模块--with-http_random_index_module不编译编译随机首页模块--with-http_secure_link_module不编译编译请求连接安全检查模块--with-http_degradation_module 不编译 编译内存不足响应模块--with-http_slice_module不编译 编译文件切片模块--with-http_stub_status_module不编译 编译运行状态模块--without-http_charset_module编译不编译字符集转换模块--without-http_gzip__module编译不编译 gzip 方式压缩输出模块--without-http_ssi_module编译不编译 SSI 支持模块--without-http_userid_module编译不编译 cookie 操作模块--without-http_access_module编译不编译基于 IP 的访问控制模块--without-http_auth_basic_module编译不编译 HTTP 基本认证模块--without-http_mirror_module编译  不编译访问镜像模块--without-http_autoindex_module编译不编译自动目录索引模块--without-http_geo_module编译不编译根据客户 IP 创建变量模块--without-http_map_module编译不编译变量映射模块--without-http_split_clients_module编译 不编译自定义客户请求分配模块--without-http_referer_module编译不编译 referer 操作模块--without-http_rewrite_module编译不编译 rewrite 规则模块--without-http_proxy_module编译不编译代理功能模块--without-http_fastcgi_module编译不编译 FastCGI 支持模块--without-http_uwsgi_module 编译不编译 uWSGI 支持模块--without-http_scgi_module编译不编译 SCGI 支持模块--without-http_grpc_module编译不编译 gRPC 支持模块--without-http_memcached_module编译不编译 Memcached 服务访问模块--without-http_limit_conn_module编译不编译并发连接数控制模块--without-http_limit_req_module编译不编译单 IP 请求数限制模块--without-http_empty_gif_module编译不编译空 GIF 图片模块--without-http_browser_module编译不编译客户端浏览器识别模块--without-http_upstream_hash_module编译不编译 hash 负载均衡算法模块--without-http_upstream_ip_hash_module编译不编译 HTTP 协议 ip-hash 负载均衡模块--without-http_upstream_least_conn_module编译不编译最少连接数算法负载均衡模块--without-http_upstream_random_module编译不编译随机选择算法负载均衡模块--without-http_upstream_keepalive_module编译不编译负载均衡后端长连接支持模块--without-http_upstream_zone_module编译不编译负载均衡共享内存支持模块--with-http_perl_module不编译编译 Perl 脚本支持模块--with-http_perl_moduledynamic--动态编译 Perl 脚本支持模块--with-stream不编译编译 TCP/UDP 代理模块--with-streamdynamic--动态编译 TCP/UDP 代理模块--with-stream_ssl_module不编译编译 TCP/UDP 代理 SSL 支持模块--with-stream_realip_module不编译编译 TCP/UDP 代理真实 IP 模块--with-stream_geoip_module不编译编译地域信息解析模块--with-stream_geoip_moduledynamic--动态编译地域信息解析模块--with-stream_ssl_preread_module不编译编译 TCP/UDP 代理的 SSL 预处理模块 4、编译 cd /data/source/ ./configure \--with-threads \--with-file-aio \--with-http_ssl_module \--with-http_v2_module \--with-http_realip_module \--with-http_addition_module \--with-http_xslt_moduledynamic \--with-http_image_filter_moduledynamic \--with-http_geoip_moduledynamic \--with-http_sub_module \--with-http_dav_module \--with-http_flv_module \--with-http_mp4_module \--with-http_gunzip_module \--with-http_gzip_static_module \--with-http_auth_request_module \--with-http_random_index_module \--with-http_secure_link_module \--with-http_degradation_module \--with-http_slice_module \--with-http_stub_status_module \--with-streamdynamic \--with-stream_ssl_module \--with-stream_realip_module \--with-stream_geoip_moduledynamic \--with-stream_ssl_preread_module \--with-compat \--with-pcre-jit make make install 编译后默认安装目录为 /usr/local/nginx。 5、添加第三方模块 5.1、查看都安装了哪些模块 /usr/local/nginx/sbin/nginx -V nginx version: nginx/1.28.0 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_moduledynamic --with-http_image_filter_moduledynamic --with-http_geoip_moduledynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-streamdynamic --with-stream_ssl_module --with-stream_realip_module --with-stream_geoip_moduledynamic --with-stream_ssl_preread_module --with-compat --with-pcre-jit5.2、下载第三方模块 5.3、添加到nginx #复制原先模块后添加第三方模块 cd /data/source/nginx-1.28.0/ ./configure --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_moduledynamic --with-http_image_filter_moduledynamic --with-http_geoip_moduledynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-streamdynamic --with-stream_ssl_module --with-stream_realip_module --with-stream_geoip_moduledynamic --with-stream_ssl_preread_module --with-compat --with-pcre-jit --with-http_ssl_module --add-module/usr/local/nginx-module-vts-0.2.4make切记不要make install 会覆盖之前的模块。 5.4、替换二进制文件 #这里复制一下原来的文件出了问题还可以还原 mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak 复制这个文件复制过去cp /data/source/nginx-1.28.0/objs/nginx /usr/local/nginx/sbin/ pkill -9 nginx ## 关闭nginx #启动nginx /usr/local/nginx/sbin/nginx .5.5、修改nginx.conf配置实验安装是否成功 http {...vhost_traffic_status_zone;vhost_traffic_status_filter_by_host on;...server {... location /status {vhost_traffic_status_display;vhost_traffic_status_display_format html;} } 配置解析 打开vhost过滤 vhost_traffic_status_filter_by_host on; 开启此功能在Nginx配置有多个server_name的情况下会根据不同的server_name进行流量的统计否则默认会把流量全部计算到第一个server_name上。 在不想统计流量的server区域禁用vhost_traffic_status配置示例 server { ... vhost_traffic_status off; ... } 5.6、启动服务 /usr/local/nginx/sbin/nginx打开浏览器访问ip/status: 5.7、安装nginx-vts-exporter wget https://github.com/hnlq715/nginx-vts-exporter/bin/nginx-vts-exporter -nginx.scrape_urihttp://172.16.254.191/status/format/json grafana 导入2949模板 四、node_export 自定义监控指标 Prometheus 的 node_exporter 是一个非常流行的导出器用于收集系统级别的指标。然而有时你可能需要监控一些自定义的指标。以下是如何配置 node_exporter 来监控自定义指标的步骤。 1、自定义监控nginx服务存活性 例如创建一个名为 custom_metrics.sh 的 Bash 脚本 #!/bin/bash echo # HELP custom_metric_example This is an example of a custom metric echo # TYPE custom_metric_example gauge echo nginx up 服务监控脚本 #!/bin/bashps -ef|grep nginx|grep -v grep /dev/null if [ $? -eq 0 ];then echo # HELP custom_metric_example This is an example of a custom metric echo # TYPE custom_metric_example gauge echo nginx_up 1 else echo # HELP custom_metric_example This is an example of a custom metric echo # TYPE custom_metric_example gauge echo nginx_up 0 2. 配置 node_exporter 以执行自定义脚本 node_exporter 支持通过 textfile 模式来导入自定义指标。你需要将自定义脚本的输出写入到一个特定的目录中node_exporter 会定期读取这个目录中的文件并将其内容作为指标导入。 创建一个目录来存放自定义指标文件 mkdir -p/data/node_exporter-1.8.2.linux-amd64/textfile_collectorsh custom_metrics.sh //data/node_exporter-1.8.2.linux/amd64/textfile_collector/custom_metrics.prom 3、添加到systemctl服务 cat/usr/lib/systemd/system/node_exporter.service [Unit] DescriptionPrometheus-Server Afternetwork.target[Service] ExecStart/data/node_exporter-1.8.2.linux-amd64/node_exporter --collector.textfile.directory/data/node_exporter-1.8.2.linux-amd64/textfile_collector --web.listen-address:9500 Userroot[Install] WantedBymulti-user.target4、启动服务 systemctl restart node_exporter #curl 请求一下看是否有数据 [rootnode1 node_exporter-1.8.2.linux-amd64]# curl 172.16.254.191:9500/metrics |grep nginx% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0# HELP nginx_up Metric read from /data/node_exporter-1.8.2.linux-amd64/textfile_collector/custom_metrics.prom # TYPE nginx_up untyped nginx_up 1 100 76559 0 76559 0 0 4662k 0 --:--:-- --:--:-- --:--:-- 4984k5、浏览器访问Prometheus是否有数据 ip端口号 6、配置自定义grafana 借鉴大佬文章 PrometheusAlertmanagerwebhook-dingtalk实现钉钉告警 - 不会游泳的鱼丶 - 博客园 (6 封私信) https://webhook.site/ - 知乎
http://www.zqtcl.cn/news/901545/

相关文章:

  • 建设工程网站资质人员查询常州模板网站建设价格
  • 自己建网站做app手机网站列表页源码
  • 企业网站模板seo网站建设关键词优化
  • 平面毕业设计作品网站推广普通话ppt
  • p2p网站开发思路方案免费建简单网站
  • 微信朋友圈的网站连接怎么做互联网工程有限公司
  • 高大上企业网站优秀的门户网站
  • 做seo对网站推广有什么作用自己做电商网站吗
  • 网站从哪些方面来做泉州网页搜索排名提升
  • 网站建设可以给公司带来想做网站开发兼职
  • 天津市免费建站精美大气的餐饮类企业网站
  • 购物网站那个信用好又便宜手机模板的网站
  • 建筑企业资质查询网站怎么查网络服务商
  • 汉川市城乡建设局网站企业销售网站建设
  • 梅州建设网站域名购买流程
  • 单页网站与传统网站的区别wordpress对接微信
  • 做公司网站深圳旅游
  • 最好企业网站网站建设 的销售图片
  • 怎么创建网站 免费滴做网站算运营吗
  • 廊坊网站建设-商昊网络正规网站优化推广
  • 网站建设拍金手指排名贰贰安装wordpress数据库错误
  • 食品网站建设需求分析购物app大全
  • 电商美工广州seo技术外包公司
  • 重庆旅游seo整站优化深圳宝安区是富人区吗
  • 网站开发验收模板网站欧美风格
  • 自己做发卡网站什么是网络设计制作
  • 如何搭建一个公司网站互联网推广怎么找客户
  • 江苏同隆建设集团有限公司网站asp.net新建网站
  • 爱站网挖掘工具小程序网站开发怎么样
  • 网站文章批量上传工具自己制作免费网站