<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>prometheus &#8211; Lhy&#039;s blog</title>
	<atom:link href="https://blog.lhyshome.com/tag/prometheus/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.lhyshome.com</link>
	<description>welcome</description>
	<lastBuildDate>Tue, 22 Apr 2025 03:27:47 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">219834889</site>	<item>
		<title>prometheus部署</title>
		<link>https://blog.lhyshome.com/2025/04/22/294/</link>
					<comments>https://blog.lhyshome.com/2025/04/22/294/#respond</comments>
		
		<dc:creator><![CDATA[lhy]]></dc:creator>
		<pubDate>Tue, 22 Apr 2025 03:23:57 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[grafana]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[prometheus]]></category>
		<guid isPermaLink="false">https://blog.lhyshome.com/?p=294</guid>

					<description><![CDATA[prometheus docker部署 prometheus.yml 配置文件 grafana docker部… <span class="read-more"><a href="https://blog.lhyshome.com/2025/04/22/294/">Read More &#187;</a></span>]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">prometheus docker部署</h2>



<pre class="wp-block-code"><code>docker run -d \
--name=prometheus \
-p 9090:9090 \
-v /home/prometheus/config/prometheus.yml:/etc/prometheus/prometheus.yml \
-v /home/prometheus/prometheus:/prometheus \
{harborPath}/prom/prometheus:v3.3.0</code></pre>



<h3 class="wp-block-heading">prometheus.yml 配置文件</h3>



<pre class="wp-block-code"><code># my global config
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).

# Alertmanager configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=&lt;job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: &#91;"{prometheus.path}"]
       # The label name is added as a label `label_name=&lt;label_value>` to any timeseries scraped from this config.
        labels:
          app: "prometheus"

  - job_name: 'Aserver'
    static_configs:
      - targets: &#91; '{Aserver.path}' ]
        labels:
          app: "Aserver"
  - job_name: 'Bserver'
    static_configs:
      - targets: &#91; '{Bserver.path}' ]
        labels:
          app: "Bserver"

  - job_name: '200mysql'
    static_configs:
      - targets: &#91;'{mysql.path}']
        labels:
          instance: "200mysql"
          app: "200mysql"</code></pre>



<h2 class="wp-block-heading">grafana docker部署</h2>



<pre class="wp-block-code"><code>docker run -d \
--name=grafana \
-p 3000:3000 \
-v /home/grafana/grafana:/var/lib/grafana \
-e "GF_SECURITY_ADMIN_PASSWORD={password}" \
{harborPath}/grafana/grafana:11.6.0</code></pre>



<h2 class="wp-block-heading">服务器监控收集器 docker部署</h2>



<pre class="wp-block-code"><code>docker run -d \
--name 200-exporter \
--restart=always \
-p 9100:9100 \
-v /proc:/host/proc:ro \
-v /sys:/host/sys:ro \
-v /:/rootfs:ro \
{harborPath}/prom/node-exporter:241003</code></pre>



<h2 class="wp-block-heading">mysql监控收集器 docker部署</h2>



<pre class="wp-block-code"><code>docker run -d \
-p 9104:9104 \
--name=mysqld-exporter \
-v /home/prometheus/mysql/.my.cnf:/.my.cnf \
{harborPath}/prom/mysqld-exporter:v0.17.2</code></pre>



<h3 class="wp-block-heading">.my.cnf 配置文件</h3>



<pre class="wp-block-code"><code>&#91;client]
user={mysql.user}
password={mysql.password}
host={mysql.host}
port={mysql.port}</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.lhyshome.com/2025/04/22/294/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">294</post-id>	</item>
	</channel>
</rss>
