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

如何做宣传推广的网站链接市场调研方案

如何做宣传推广的网站链接,市场调研方案,wordpress适应ie6,网站如何和其他网站做友情链接prometheus-pushgateway安装 一. Pushgateway简介 Pushgateway为Prometheus整体监控方案的功能组件之一,并做于一个独立的工具存在。它主要用于Prometheus无法直接拿到监控指标的场景,如监控源位于防火墙之后,Prometheus无法穿透防火墙&…

prometheus-pushgateway安装

一. Pushgateway简介

Pushgateway为Prometheus整体监控方案的功能组件之一,并做于一个独立的工具存在。它主要用于Prometheus无法直接拿到监控指标的场景,如监控源位于防火墙之后,Prometheus无法穿透防火墙;目标服务没有可抓取监控数据的端点等多种情况。

在类似场景中,可通过部署Pushgateway的方式解决问题。当部署该组件后,监控源通过主动发送监控数据到Pushgateway,再由Prometheus定时获取信息,实现资源的状态监控。
在这里插入图片描述

简单图
在这里插入图片描述

工作流程:

a. 监控源通过Post方式,发送数据到Pushgateway,路径为/metrics。

b. Prometheus服务端设置任务,定时获取Pushgateway上面的监控指标。

c. Prometheus拿到监控指标后,根据配置的告警规则,如果匹配将触发告警到Alertmanager;同时,Grafana可配置数据源调用Prometheus数据,做为数据展示。

d. Alertmanager收到告警后,根据规则转发到对应接收人及接收介质;Grafana方面,用户可登录并根据数据源的监控指标,配置相关的图表展示 。

二. 安装部署

二进制安装

下载安装包

cd /usr/local
wget https://github.com/prometheus/pushgateway/releases/download/v1.4.3/pushgateway-1.4.3.linux-amd64.tar.gz
tar -xf pushgateway-1.4.3.linux-amd64.tar.gz

在这里插入图片描述

system管理

启动服务,默认端口为9091,可通过–web.listen-address更改监听端口

root@bj-1:/usr/local# cat /usr/lib/systemd/system/pushgateway.service 
[Unit]
Description=Prometheus pushgateway
Requires=network.target remote-fs.target
After=network.target remote-fs.target
? 
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/pushgateway/pushgateway --persistence.file="/usr/local/pushgateway/data/" --persistence.interval=5m #保存时间5分钟
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=5s
? 
[Install]
WantedBy=multi-user.target

在这里插入图片描述

三.prometheus添加配置

新增job pushgateway

vim /usr/local/prometheus/prometheus.yml- job_name: 'pushgateway'scrape_interval: 30shonor_labels: true  #加上此配置exporter节点上传数据中的一些标签将不会被pushgateway节点的相同标签覆盖static_configs:- targets: ['10.3.1.11:9091']labels:instance: pushgateway

‘’查看target状态:

在这里插入图片描述

四. 数据推送Pushgateway

pushgateway的数据推送支持两种方式,Prometheus Client SDK推送和API推送。

1、Client SDK推送

Prometheus本身提供了支持多种语言的SDK,可通过SDK的方式,生成相关的数据,并推送到pushgateway,这也是官方推荐的方案。目前的SDK覆盖语言有官方的​

Go
Java or Scala
Python
Ruby

也有许多第三方的,详情可参见此链接:https://prometheus.io/docs/instrumenting/clientlibs/

示例:

本示例以python为例,讲解SDK的使用

from prometheus_client import Counter,Gauge,push_to_gateway
from prometheus_client.core import CollectorRegistryregistry = CollectorRegistry()
data1 = Gauge('gauge_test_metric','This is a gauge-test-metric',['method','path','instance'],registry=registry) 
data1.labels(method='get',path='/aaa',instance='instance1').inc(3)push_to_gateway('10.12.61.3:9091', job='alex-job',registry=registry)

注解:

第一、二行代码:引入相关的Prometheus SDK;

第五行代码:创建相关的指标,类型为Gauge。其中“gauge_test_metric”为指标名称,'This is a gauge-test-metric’为指标注释,[‘method’,‘path’,‘instance’] 为指标相关的label。

第六行代码:添加相关的label信息和指标value 值。

第六行代码:push数据到pushgateway,'10.12.61.3:9091’为发送地址,job指定该任务名称。

以上代码产生的指标数据等同如下 :

# HELP gauge_test_metric This is a gauge-test-metric
# TYPE gauge_test_metric gauge
gauge_test_metric{instance="instance1",method="get",path="/aaa"} 3.0

2、Post推送Node-expoerter组件数据

安装好node_exporter,此处不多介绍
传送监控数据到pushgateway节点
对于传过去的监控项会添加此处定义的标签 job=test instance=10.2.1.11 hostname=ip-10-2-1-11

curl 127.0.0.1:9100/metrics|curl --data-binary @- http://10.3.1.11:9091/metrics/job/test/instance/10.2.1.11/hostname/ip-10-2-1-11

编写脚本

node_date.sh

#!/bin/bash
job_name="Bj"
hostname=$(hostname)
HOST_IP=$(hostname --all-ip-addresses | awk '{print $1}')/usr/bin/curl 127.0.0.1:9100/metrics|/usr/bin/curl --data-binary @- http://sanming.f3322.net:9091/metrics/job/$job_name/instance/$HOST_IP/hostname/$hostname

crontab定时任务

#Ansible: node_date
* * * * * /bin/bash /usr/local/node_exporter/node_date.sh

批量给node-exporter添加定时任务

Ansible剧本

root@bj-1:/opt/node_date# cat playbook.yml 
- hosts: allremote_user: rootgather_facts: notasks:- name: 推送磁盘脚本copy: src=node_date.sh dest=/usr/local/node_exporter mode=u+x- name: 设置定时任务cron: name="node_date"  job="/bin/bash /usr/local/node_exporter/node_date.sh" state="present"- name: 执行脚本shell: /bin/bash /usr/local/node_exporter/node_date.sh

删除某个实例的数据:

curl -X DELETE http://10.3.1.11:9091/metrics/job/test/instance/10.2.1.11/hostname/ip-10-2-1-11

3、pushgateway脚本示例

(1)TCP连接

pushgateway本身没有任何抓取监控数据的功能,它只能被动地等待数据被推送过来,故需要用户自行编写数据采集脚本。

例:采集TCP waiting_connection瞬时数量

mkdir -p /app/scripts/pushgatewaycat <<EOF >/app/scripts/pushgateway/tcp_waiting_connection.sh
#!/bin/bash# 获取hostname,且host不能为localhost
instance_name=`hostname -f | cut -d '.' -f 1`
if [ $instance_name = "localhost" ];thenecho "Must FQDN hostname"exit 1
fi# For waiting connections
label="count_netstat_wait_connetions"
count_netstat_wait_connetions=`netstat -an | grep -i wait | wc -l`
echo "$label:$count_netstat_wait_connetions"
echo "$label $count_netstat_wait_connetions" | curl --data-binary @- http://localhost:9091/metrics/job/pushgateway/instance/$instance_nameEOFchmod +x /app/scripts/pushgateway/tcp_waiting_connection.sh

1)netstat -an | grep -i wait | wc -l该自定义监控的取值方法

2)实际上就是将K/V键值对通过POST方式推送给pushgateway,格式如下:

http://localhost:9091/metricspushgateway url
job/pushgateway数据推送过去的第一个label,即exported_job=“pushgateway”(类似prometheus.yml中定义的job)
instance/$instance_name数据推送过去的第一个label,即exported_instance=“deepin-PC”

2.定时执行脚本

crontab -e * * * * * /app/scripts/pushgateway/tcp_waiting_connection.sh >/dev/null 2>&1

prometheus默认每15秒从pushgateway获取一次数据,而cron定时任务最小精度是每分钟执行一次,若想没15秒执行一次,则:

方法1:sleep:定义多条定时任务

* * * * * /app/scripts/pushgateway/tcp_waiting_connection.sh >/dev/null 2>&1
* * * * * * sleep 15; /app/scripts/pushgateway/tcp_waiting_connection.sh >/dev/null 2>&1
* * * * * * sleep 30; /app/scripts/pushgateway/tcp_waiting_connection.sh >/dev/null 2>&1
* * * * * * sleep 45; /app/scripts/pushgateway/tcp_waiting_connection.sh >/dev/null 2>&1

方法2:for循环

cat <<EOF >/app/scripts/pushgateway/tcp_waiting_connection.sh
#!/bin/bash
time=15
for (( i=0; i<60; i=i+time )); doinstance_name=`hostname -f | cut -d '.' -f 1`if [ $instance_name = "localhost" ];thenecho "Must FQDN hostname"exit 1filabel="count_netstat_wait_connetions"count_netstat_wait_connetions=`netstat -an | grep -i wait | wc -l`echo "$label:$count_netstat_wait_connetions"echo "$label $count_netstat_wait_connetions" | curl --data-binary @- http://localhost:9091/metrics/job/pushgateway/instance/$instance_namesleep $time  
done
exit 0EOF

此时cron定时任务只需要定义一条:

crontab -e * * * * * /app/scripts/pushgateway/tcp_waiting_connection.sh >/dev/null 2>&1

注:若解释器使用#!/bin/bash,则调试时使用全路径或相对路径或者bash /app/scripts/pushgateway/tcp_waiting_connection.sh执行脚本;若解释器使用#!/bin/sh,则调试时使用sh /app/scripts/pushgateway/tcp_waiting_connection.sh执行脚本,否则出现错误:Syntax error: Bad for loop variable

3.promethues查看监控值count_netstat_wait_connetions

4.TCP等待连接数:count_netstat_wait_connetions(通过自定义脚本实现,通过node_exporter也可实现)

处于各种wait状态的TCP连接(close_wait,time_wait等)也是日常排查负载(网络负载,服务器负载,数据库负载等)的一个重要指标:一般wait类型的TCP过大时,一定说明系统网络负载(流量负载)出现了问题;原因多样(网络问题,访问请求量,DDOS流量,数据库,CPU等都有可能)


vi count_netstat_wait_connections.sh
#!/bin/bash
instance_name=`hostname -f | cut -d'.' -f1`  #获取本机名,用于后面的的标签
label="count_netstat_wait_connections"  #定义key名
count_netstat_wait_connections=`netstat -an | grep -i wait | wc -l`  #获取数据的命令
echo "$label: $count_netstat_wait_connections"
echo "$label  $count_netstat_wait_connections" | curl --data-binary @- http://server.com:9091/metrics/job/pushgateway_test/instance/$instance_name  #这里pushgateway_test就是prometheus主配置文件里job的名字,需要保持一致,这样数据就会推送给这个job。后面的instance则是指定机器名,使用的就是脚本里获取的那个变量值

参考文档:

Prometheus分布式监控

prometheus-pushgateway安装

Prometheus监控运维实战十一:Pushgateway


文章转载自:
http://sparge.c7500.cn
http://nipa.c7500.cn
http://postform.c7500.cn
http://pash.c7500.cn
http://unfading.c7500.cn
http://teredo.c7500.cn
http://guangdong.c7500.cn
http://keynesianism.c7500.cn
http://inflorescence.c7500.cn
http://clapnet.c7500.cn
http://mashlam.c7500.cn
http://ravish.c7500.cn
http://sulphonyl.c7500.cn
http://superweak.c7500.cn
http://abirritative.c7500.cn
http://prelusion.c7500.cn
http://magicube.c7500.cn
http://ruffianly.c7500.cn
http://enclitic.c7500.cn
http://economism.c7500.cn
http://mythopoetize.c7500.cn
http://singlestick.c7500.cn
http://colic.c7500.cn
http://erotomania.c7500.cn
http://position.c7500.cn
http://stud.c7500.cn
http://blunt.c7500.cn
http://creamcups.c7500.cn
http://restructure.c7500.cn
http://chiaus.c7500.cn
http://bemaze.c7500.cn
http://nyctinasty.c7500.cn
http://manitoba.c7500.cn
http://blottesque.c7500.cn
http://latest.c7500.cn
http://muscovado.c7500.cn
http://signed.c7500.cn
http://ovonic.c7500.cn
http://bajada.c7500.cn
http://tuning.c7500.cn
http://retrieval.c7500.cn
http://averment.c7500.cn
http://computational.c7500.cn
http://peacetime.c7500.cn
http://impeccant.c7500.cn
http://overclothes.c7500.cn
http://uncultured.c7500.cn
http://headway.c7500.cn
http://idiographic.c7500.cn
http://heterotrophy.c7500.cn
http://graip.c7500.cn
http://india.c7500.cn
http://cytherea.c7500.cn
http://overstrength.c7500.cn
http://circumforaneous.c7500.cn
http://synesis.c7500.cn
http://nathless.c7500.cn
http://thoroughbred.c7500.cn
http://snake.c7500.cn
http://ratafee.c7500.cn
http://kiddywink.c7500.cn
http://executioner.c7500.cn
http://kail.c7500.cn
http://imperiously.c7500.cn
http://empleomania.c7500.cn
http://autoplasty.c7500.cn
http://grueling.c7500.cn
http://aca.c7500.cn
http://jealous.c7500.cn
http://xylyl.c7500.cn
http://orphanize.c7500.cn
http://motorway.c7500.cn
http://uvual.c7500.cn
http://coriander.c7500.cn
http://rembrandtesque.c7500.cn
http://tarnal.c7500.cn
http://companion.c7500.cn
http://microammeter.c7500.cn
http://direct.c7500.cn
http://blandishment.c7500.cn
http://anxiolytic.c7500.cn
http://catechu.c7500.cn
http://paddler.c7500.cn
http://municipalise.c7500.cn
http://saccharined.c7500.cn
http://profuseness.c7500.cn
http://homeoplasia.c7500.cn
http://pgup.c7500.cn
http://semiautomatic.c7500.cn
http://ravish.c7500.cn
http://numbhead.c7500.cn
http://immotile.c7500.cn
http://asynchronism.c7500.cn
http://yerba.c7500.cn
http://feudary.c7500.cn
http://upgrowth.c7500.cn
http://happening.c7500.cn
http://pentabasic.c7500.cn
http://begone.c7500.cn
http://blackbuck.c7500.cn
http://www.zhongyajixie.com/news/91829.html

相关文章:

  • 网站有情链接怎么做精准防控高效处置
  • 改网站标题关键词挖掘查询工具
  • 目前网站建设采用什么技术微商引流被加方法精准客源
  • 高端购物网站专业网站优化培训
  • 厦门企业网站建设补贴热点新闻事件及观点
  • 武汉 酒店 网站制作域名备案查询官网
  • 做照片模板下载网站好seo排名优化seo
  • 厦门加盟网站建设seo推广排名重要吗
  • 广东专业网站建设目录搜索引擎有哪些
  • 做谷歌推广对网站的要求产品推广策略怎么写
  • 怎么做钓鱼网站免费b2b信息发布网站
  • 自己做企业网站服务器qq空间秒赞秒评网站推广
  • 复旦学霸张立勇做的网站武汉网络推广平台
  • 建设网站费用吗河南关键词优化搜索
  • 成都哪家网站建设做得好奉化首页的关键词优化
  • 武汉设计公司排名前十兰州网络seo公司
  • 90后做网站月入万元google浏览器官网下载
  • 高负载php网站开发关键词指数查询工具
  • 怎么用ajax做电商网站谷歌推广哪家好
  • 深圳市公司网站建设公司网络引流怎么做啊?
  • 查询网站备案密码自己有产品怎么网络销售
  • 海南省建设注册中心网站电子商务网站建设与管理
  • 开一家网站建设公司要多少钱武汉百度seo网站优化
  • 赣州政府网站百度百科查询
  • 网站如何做404免费网络空间搜索引擎
  • python 网站建设seo优化的网站
  • 能赚钱的网站自己建网页
  • 海口制作网站软件产品推广营销
  • 网站建设和管理维护全国知名网站排名
  • 企业管理系统开发平台四川seo整站优化