Prometheus學習之pushgateway和altermanager組件

[root@node-exporter41 /usr/local/alertmanager-0.28.1.linux-amd64]# pwd
/usr/local/alertmanager-0.28.1.linux-amd64[root@node-exporter41 /usr/local/alertmanager-0.28.1.linux-amd64]# cat alertmanager.yml 
# 通用配置
global:resolve_timeout: 5msmtp_from: '914XXXXXX@qq.com'smtp_smarthost: 'smtp.qq.com:465'smtp_auth_username: '914XXXXXX@qq.com'smtp_auth_password: 'aalXXXjXXbXa'smtp_require_tls: falsesmtp_hello: 'qq.com'
# 定義路由信息
route:group_by: ['alertname']group_wait: 5sgroup_interval: 5srepeat_interval: 5mreceiver: 'sre_system'# 配置子路由routes:- receiver: 'sre_ops'match_re:job: linux96_ops_exporter# 建議將continue的值設置為true,表示當前的條件是否匹配,都將繼續向下匹配規則# 這樣做的目的是將消息發給最后的系統組(sre_system)continue: true- receiver: 'sre_k8s'match_re:job: linux96_k8s_exporter continue: true- receiver: 'sre_system'match_re:job: .*continue: true
# 定義接受者 
receivers:
- name: 'sre_ops'email_configs:- to: '914XXXXX@qq.com'send_resolved: true- to: '914XXXXX@qq.com'send_resolved: true
- name: 'sre_k8s'email_configs:- to: '568XXXX@qq.com'send_resolved: true- to: '56XXXX@qq.com'send_resolved: true
- name: 'sre_system'email_configs:- to: '914XXXXX@qq.com'send_resolved: true- to: '56XXXXXX@qq.com'send_resolved: true

引言

在深入探索 Prometheus 的過程中,我們往往會對其核心組件有較為深入的了解,但與此同時,一些輔助組件也發揮著不可或缺的作用,它們就像是為整個監控系統增添羽翼的利器,讓監控功能得以進一步拓展和完善。今天,我們就來聚焦于 Prometheus 生態系統中的兩個重要組件 ——Pushgateway 和 Alertmanager,深入剖析它們的工作原理、應用場景以及與整個 Prometheus 監控體系的協同合作方式,一同揭開它們在監控領域所蘊含的巨大潛力和價值,為你的技術監控之旅增添新的助力和洞察。

一、背景

隨著互聯網行業的蓬勃發展,各種復雜的應用系統和微服務架構層出不窮,這些系統的正常運轉對于企業的業務運營至關重要。為了確保這些系統能夠以最佳狀態持續運行,及時發現和解決潛在的問題,監控系統成為了不可或缺的基礎設施。

Prometheus 作為一款開源的監控告警系統,以其強大的數據模型、靈活的查詢語言(PromQL)以及高效的時序數據庫等優勢,在眾多監控解決方案中脫穎而出。它采用拉取(Pull)模式來收集被監控目標的指標數據,這種模式在大多數場景下能夠很好地工作,但在某些特殊場景,例如需要監控短生命周期的批處理任務、臨時性的任務或者在防火墻受限的環境中等,僅僅依靠 Prometheus 的拉取模式就顯得有些力不從心了,這就促使了 Pushgateway 這樣一個組件的誕生,它允許客戶端將指標數據推送到 Prometheus 中,從而彌補了拉取模式在這些特殊場景下的不足。

而另一方面,在監控過程中,當發現指標數據出現異常時,及時準確地發出告警通知對于快速響應和處理問題是至關重要的。雖然 Prometheus 自身具備一定的告警規則配置功能,但當涉及到復雜的告警通知策略、告警分組、抑制以及與多種通知渠道的集成等場景時,單獨使用 Prometheus 的告警功能就會顯得較為復雜和局限,此時 Alertmanager 便應運而生。它作為 Prometheus 的告警管理組件,專門負責處理來自 Prometheus Server 的告警信息,對告警進行分組、去重、抑制等處理,并能夠根據預設的規則將告警通過多種方式(如郵件、Slack、PagerDuty 等)發送給相應的接收者,從而構建起一個完善且高效的告警通知體系。

通過對 Pushgateway 和 Alertmanager 這兩個組件的深入學習和應用,我們能夠使 Prometheus 監控系統在更多復雜多變的場景下發揮出更大的威力,為系統的穩定運行提供更加堅實可靠的保障。在接下來的博客內容中,我們將分別對這兩個組件進行詳細講解,包括它們的安裝部署、配置使用、實際案例分析等多個方面,希望能幫助你更好地掌握和運用這些強大的監控工具。

二、 Pushgateway組件部署

1. 下載軟件包

部署pushgateway 
[root@node-exporter41 ~]# wget https://github.com/prometheus/pushgateway/releases/download/v1.11.0/pushgateway-1.11.0.linux-amd64.tar.gz解壓軟件包 
[root@node-exporter41 ~]# tar xf pushgateway-1.11.0.linux-amd64.tar.gz -C /usr/local/bin/ pushgateway-1.11.0.linux-amd64/pushgateway --strip-components=1
[root@node-exporter41 ~]# 
[root@node-exporter41 ~]# ll /usr/local/bin/pushgateway 
-rwxr-xr-x 1 1001 1002 20656129 Jan  9 22:36 /usr/local/bin/pushgateway*
[root@node-exporter41 ~]# 

2.?運行pushgateway?

[root@node-exporter41 ~]# pushgateway --web.telemetry-path="/metrics" --web.listen-address=:9091 --persistence.file=/data/pushgateway.data訪問pushgateway的WebUI
http://10.0.0.41:9091/#

3. 使用pushgateway監控TCP的12種狀態

[root@elk93 ~]# cat /usr/local/bin/tcp_status2.sh
#!/bin/bashpushgateway_url="http://10.0.0.41:9091/metrics/job/tcp_status"
time=$(date +%Y-%m-%d+%H:%M:%S)state="SYN-SENT SYN-RECV FIN-WAIT-1 FIN-WAIT-2 TIME-WAIT CLOSE CLOSE-WAIT LAST-ACK LISTEN CLOSING ESTAB"
for i in  $statedot=`ss -tan |grep $i |wc -l`echo tcp_connections{state=\""$i"\"} $t >>/tmp/tcp.txt
done;cat /tmp/tcp.txt | curl --data-binary @- $pushgateway_url
rm -rf  /tmp/tcp.txt
[root@elk93 ~]# 2.調用腳本
[root@elk93 ~]# bash /usr/local/bin/tcp_status2.sh

三、Alertmanager單機環境部署

1. 下載軟件包

2.下載Alertmanager 
wget https://github.com/prometheus/alertmanager/releases/download/v0.28.1/alertmanager-0.28.1.linux-amd64.tar.gz3.解壓安裝包 
[root@node-exporter43 ~]# tar xf alertmanager-0.28.1.linux-amd64.tar.gz  -C /usr/local/
[root@node-exporter43 ~]# 

2. 修改Alertmanager的配置文件

[root@node-exporter41 /usr/local/alertmanager-0.28.1.linux-amd64]# pwd
/usr/local/alertmanager-0.28.1.linux-amd64[root@node-exporter41 /usr/local/alertmanager-0.28.1.linux-amd64]# cat alertmanager.yml 
# 通用配置
global:resolve_timeout: 5msmtp_from: '914@qq.com'smtp_smarthost: 'smtp.qq.com:465'smtp_auth_username: '914@qq.com'smtp_auth_password: 'ahjplbbja'smtp_require_tls: falsesmtp_hello: 'qq.com'
# 定義路由信息
route:group_by: ['alertname']group_wait: 5sgroup_interval: 5srepeat_interval: 5mreceiver: 'sre_system'# 配置子路由routes:- receiver: 'sre_ops'match_re:job: linux96_ops_exporter# 建議將continue的值設置為true,表示當前的條件是否匹配,都將繼續向下匹配規則# 這樣做的目的是將消息發給最后的系統組(sre_system)continue: true- receiver: 'sre_k8s'match_re:job: linux96_k8s_exporter continue: true- receiver: 'sre_system'match_re:job: .*continue: true
# 定義接受者 
receivers:
- name: 'sre_ops'email_configs:- to: '914@qq.com'send_resolved: true- to: '914@qq.com'send_resolved: true
- name: 'sre_k8s'email_configs:- to: '5@qq.com'send_resolved: true- to: '5689@qq.com'send_resolved: true
- name: 'sre_system'email_configs:- to: '914@qq.com'send_resolved: true- to: '56@qq.com'send_resolved: true

3.?檢查配置是否正確

[root@node-exporter41 /usr/local/alertmanager-0.28.1.linux-amd64]# ./amtool check-config alertmanager.yml 
Checking 'alertmanager.yml'  SUCCESS
Found:- global config- route- 0 inhibit rules- 3 receivers- 0 templates

4. 啟動Alertmanager服務并測試

[root@node-exporter43 alertmanager-0.28.1.linux-amd64]# ./alertmanager # 訪問webUI測試
http://10.0.0.41:9093/#/status

四、Prometheus server集成Alertmanager實現告警功能

1. 修改Prometheus配置文件,打開告警功能

[root@prometheus-server31 /softwares/prometheus-2.53.4.linux-amd64]# cat prometheus.yml
# my global config
global:scrape_interval: 3s # 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   ------------------->打開此alter的配置信息~~
alerting:alertmanagers:- static_configs:- targets:- 10.0.0.41:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:                   ------------------> 此配置是告警規則可以自定義# - "first_rules.yml"# - "second_rules.yml"- "linux96-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=<job_name>` to any timeseries scraped from this config.- job_name: "prometheus"# metrics_path defaults to '/metrics'# scheme defaults to 'http'.static_configs:- targets: ["localhost:9090"]# 這里就是靜態配置- job_name: "linux96_ops_exporter"static_configs:- targets:- 10.0.0.41:9100- job_name: "linux96_k8s_exporter"static_configs:- targets:- 10.0.0.42:9100- job_name: "whatever_job_exporter"static_configs:- targets:- 10.0.0.43:9100

2.?編寫告警配置

[root@prometheus-server31 /softwares/prometheus-2.53.4.linux-amd64]# cat linux96-rules.yml 
groups:
- name: linux96-rules-alertrules:- alert: linux96-rules-ops-alertexpr: up{job="linux96_ops_exporter"} == 0for: 3slabels:address: Shanghai class: linux96apps: opsannotations:summary: "{{ $labels.instance }} 服務器已經停止運行超過 3s!!!!!"- alert: linux96-rules-k8s-alterexpr: up{job="linux96_k8s_exporter"} == 0for: 3slabels:school: Beijingclass: linux96apps: k8sannotations:summary: "{{ $labels.instance }} K8S服務器已停止運行超過 3s!"- alert: othersServer-rules-system-alterexpr: up{job="whatever_job_exporter"} == 0for: 5slabels:school: Shenzhenclass: linux96apps: bigdataannotations:summary: "{{ $labels.instance }} 大數據服務器已停止運行超過 5s!"

3.?檢查配置文件語法并重新加載配置

[root@prometheus-server31 /softwares/prometheus-2.53.4.linux-amd64]# ./promtool check config prometheus.yml
Checking prometheus.ymlSUCCESS: 1 rule files foundSUCCESS: prometheus.yml is valid prometheus config file syntaxChecking linux96-rules.ymlSUCCESS: 3 rules found[root@prometheus-server31 /softwares/prometheus-2.53.4.linux-amd64]# ### 重新加載prometheus的配置
curl -X POST http://10.0.0.31:9090/-/reload

4.?觸發告警功能

[root@node-exporter41 ~]# systemctl stop node-exporter.service 
[root@node-exporter41 ~]# ss -ntl | grep 9100
[root@node-exporter41 ~]# [root@node-exporter42 ~]# systemctl stop  node-exporter.service 
[root@node-exporter42 ~]# 
[root@node-exporter42 ~]# ss -ntl | grep 9100
[root@node-exporter42 ~]# [root@node-exporter43 ~]# systemctl stop node-exporter.service 
[root@node-exporter43 ~]# 
[root@node-exporter43 ~]# ss -ntl | grep 9100

5.?查看alermanager的WebUI及郵箱接受者

由此webUI可以發現我們的ops模塊異常了

此時郵箱就會出現告警

?這時候我們去修復一下服務

[root@node-exporter41 /usr/local/alertmanager-0.28.1.linux-amd64]# systemctl start node-exporter.service 
[root@node-exporter41 /usr/local/alertmanager-0.28.1.linux-amd64]# ss -ntl |grep 9100
LISTEN 0      4096               *:9100            *:*  

此時郵箱依舊會發送郵件告訴我們故障已解決

五、Alertmanager集成釘釘插件實現告警

參考鏈接:
?? ?https://github.com/timonwong/prometheus-webhook-dingtalk/

1.部署釘釘插件

	1.1 下載釘釘插件 
wget https://github.com/timonwong/prometheus-webhook-dingtalk/releases/download/v2.1.0/prometheus-webhook-dingtalk-2.1.0.linux-amd64.tar.gz1.2 解壓文件
[root@node-exporter43 ~]# tar xf prometheus-webhook-dingtalk-2.1.0.linux-amd64.tar.gz  -C /usr/local/
[root@node-exporter43 ~]# 
[root@node-exporter43 ~]# cd /usr/local/prometheus-webhook-dingtalk-2.1.0.linux-amd64/
[root@node-exporter43 prometheus-webhook-dingtalk-2.1.0.linux-amd64]# 
[root@node-exporter43 prometheus-webhook-dingtalk-2.1.0.linux-amd64]# ll
total 18752
drwxr-xr-x  3 3434 3434     4096 Apr 21  2022 ./
drwxr-xr-x 12 root root     4096 Mar 30 17:47 ../
-rw-r--r--  1 3434 3434     1299 Apr 21  2022 config.example.yml
drwxr-xr-x  4 3434 3434     4096 Apr 21  2022 contrib/
-rw-r--r--  1 3434 3434    11358 Apr 21  2022 LICENSE
-rwxr-xr-x  1 3434 3434 19172733 Apr 21  2022 prometheus-webhook-dingtalk*
[root@node-exporter43 prometheus-webhook-dingtalk-2.1.0.linux-amd64]# [root@node-exporter43 /usr/local/prometheus-webhook-dingtalk-2.1.0.linux-amd64]# cp config{.example,}.yml 
[root@node-exporter43 /usr/local/prometheus-webhook-dingtalk-2.1.0.linux-amd64]# ll
total 18756
drwxr-xr-x  3 3434 3434     4096 Mar 30 13:47 ./
drwxr-xr-x 11 root root     4096 Mar 30 13:46 ../
-rw-r--r--  1 3434 3434     1299 Apr 21  2022 config.example.yml
-rw-r--r--  1 root root     1299 Mar 30 13:47 config.yml
drwxr-xr-x  4 3434 3434     4096 Apr 21  2022 contrib/
-rw-r--r--  1 3434 3434    11358 Apr 21  2022 LICENSE
-rwxr-xr-x  1 3434 3434 19172733 Apr 21  2022 prometheus-webhook-dingtalk*
[root@node-exporter43 /usr/local/prometheus-webhook-dingtalk-2.1.0.linux-amd64]# 

?2.?登錄釘釘添加自定義機器人

保存好配置文件信息

webhook地址:
https://oapi.dingtalk.com/robot/send?access_token=4b1f23e7286ebce1f626474534050d1cb3868f5055914d77d9217

加簽信息:
SEC6a9472f35ce08bd855c5e5b8cf3b39fd57fdb99d650aa35786acd884b9e

3.?配置釘釘的config.yml

[root@node-exporter43 /usr/local/prometheus-webhook-dingtalk-2.1.0.linux-amd64]# vim config.yml 
## Request timeout
.....
### 配置釘釘的config.yml
## Targets, previously was known as "profiles"
targets:webhook1:url: https://oapi.dingtalk.com/robot/send?access_token=4b1f23e7286ebce1f624dff7c4eb236474534050d1cb3868f5055914d77d9217# secret for signaturesecret: SEC6a9472f35ce08bd855c5e5b8eb2a4cf3b39fd57fdb99d650aa35786acd884b9e
.....
當前只要一個自定觸發的鉤子,如果有多個可以繼續寫

4.?啟動釘釘

[root@node-exporter43 /usr/local/prometheus-webhook-dingtalk-2.1.0.linux-amd64]# ./prometheus-webhook-dingtalk --web.listen-address="10.0.0.43:8060"
..........
這里有URL和一些messages
ts=2025-03-30T14:07:59.409Z caller=main.go:97 level=info component=configuration msg="Loading templates" templates=
ts=2025-03-30T14:07:59.410Z caller=main.go:113 component=configuration msg="Webhook urls for prometheus alertmanager" urls=http://10.0.0.43:8060/dingtalk/webhook1/send
ts=2025-03-30T14:07:59.411Z caller=web.go:208 level=info component=web msg="Start listening for connections" address=10.0.0.43:8060

5.?Alertmanager集成釘釘插件

[root@node-exporter41 /usr/local/alertmanager-0.28.1.linux-amd64]# vim alertmanager.yml .....### 添加此配置- name: 'sre_system'webhook_configs:# 指向的是DingDing的插件地址- url: 'http://10.0.0.43:8060/dingtalk/webhook1/send'http_config: {}max_alerts: 0send_resolved: true#- name: 'sre_system'#  email_configs:#  - to: '94@qq.com'#    send_resolved: true#    headers: { Subject: "[WARN] LINUX96報警郵件" }
"alertmanager.yml" 76L, 2274B written   

6. 測試

[root@node-exporter43 ~]# systemctl stop node-exporter.service?
[root@node-exporter43 ~]#?

六.?Alertmanager的告警靜默(Silence)

1.告警靜默(Silence)
一般用于系統維護,預期要做的操作,這意味著就沒有必要告警。

比如系統升級,需要8h,在這8h過程中,就可以考慮先不用告警。

這時候就可以說明當前標簽為K8S規則的節點正在靜默,所以他即使有問題也不會報警,相反其他節點就可以正常。

測試

[root@node-exporter42 ~]# systemctl stop node-exporter.service 
[root@node-exporter43 ~]# systemctl stop node-exporter.service 我們就可以看到42的k8s的警告就被靜默了,但是43還是正常報警

打開靜默就發現了K8S

機器人的報警也是一樣的

沒有k8s標簽的警告

恢復節點
[root@node-exporter42 ~]# systemctl start node-exporter.service 
[root@node-exporter43 ~]# systemctl start node-exporter.service 

?七、Alertmanager的告警抑制(inhibit)

1.什么是告警抑制
說白了,就是抑制告警,和靜默不同的是,抑制的應用場景一般用于抑制符合條件的告警。

舉個例子:?
?? ?一個數據中心有800臺服務器,每臺服務器有50個監控項,假設一個意味著有4w個監控告警。
?? ?如果數據中心端點,理論上來說就會有4w條告警發送到你的手機,你是處理不過來的,所以我們只需要將數據中心斷電的告警發出來即可。

1.?Prometheus編寫規則

### 主要添加severity: criticaldc: beijing
這兩行,標志著報警的級別和(可以理解為)標簽[root@prometheus-server31 /softwares/prometheus-2.53.4.linux-amd64]# vim linux96-rules.yml 
- name: linux96-rules-alertrules:
groups:
- name: linux96-rules-alertrules:- alert: linux96-rules-ops-alertexpr: up{job="linux96_ops_exporter"} == 0for: 3slabels:address: Shanghaiclass: linux96apps: opsseverity: criticaldc: beijingannotations:summary: "{{ $labels.instance }} 服務器已經停止運行超過 3s!!!!!"- alert: linux96-rules-k8s-alterexpr: up{job="linux96_k8s_exporter"} == 0for: 3slabels:school: Beijingclass: linux96apps: k8sseverity: warningdc: beijingannotations:summary: "{{ $labels.instance }} K8S服務器已停止運行超過 3s!"- alert: othersServer-rules-system-alterexpr: up{job="whatever_job_exporter"} == 0for: 5slabels:school: Shenzhenclass: linux96apps: bigdataseverity: warningdc: Shenzhenannotations:summary: "{{ $labels.instance }} 大數據服務器已停止運行超過 5s!"
"linux96-rules.yml" 36L, 981B written 

?2.?Alertmanager配置告警抑制規則?

......
### 在最后加入
## 配置告警抑制規則
inhibit_rules:# 如果"dc"的值相同的前提條件下。#	則當觸發了"severity: critical"告警,就會抑制"severity: warning"的告警信息。
- source_match:severity: criticaltarget_match:severity: warningequal:- dc

3.?啟動Alertmanager&&DingDing

[root@node-exporter43 prometheus-webhook-dingtalk-2.1.0.linux-amd64]# ./prometheus-webhook-dingtalk --web.listen-address="10.0.0.43:8060" [root@node-exporter43 alertmanager-0.28.1.linux-amd64]# ./alertmanager 

4.?停止服務在釘釘驗證

[root@node-exporter41 ~]# systemctl stop node-exporter.service 
[root@node-exporter42 ~]# systemctl stop node-exporter.service 
### 這里故意停止了相同的equal指標但是警告等級不一樣,這時候只會報警我們警告時(災難)嚴重級別的節點信息。

[root@node-exporter43 ~]# systemctl stop node-exporter.service?
再停止一個43節點不同equal指標的,當然就可以正常通知了

5. 恢復測試?

如果恢復了就正常恢復報警
[root@node-exporter41 ~]# systemctl start node-exporter.service
[root@node-exporter42 ~]# systemctl start node-exporter.service
[root@node-exporter43 ~]# systemctl start node-exporter.service?

八、總結

在本博客中,我們深入探討了 Prometheus 生態系統中的兩個重要組件 ——Pushgateway 和 Alertmanager。通過學習和實踐,我們了解到 Pushgateway 在特殊場景下(如短生命周期任務、防火墻限制等)彌補了 Prometheus 拉模式的不足,能夠接收客戶端推送的指標數據并臨時存儲,以便 Prometheus Server 進行拉取監控。我們還了解到 Alertmanager 的強大功能,它負責處理來自 Prometheus Server 的告警信息,實現了告警的分組、去重、抑制以及靈活的通知方式,使得告警系統更加高效和智能。

同時,我們還通過示例腳本的講解,掌握了如何利用 Pushgateway 來推送自定義的 TCP 連接狀態指標數據,進一步拓展了 Prometheus 的監控能力。理解并熟練運用 Pushgateway 和 Alertmanager 這兩個組件,對于我們構建一個完整、高效、可靠的監控告警體系具有重要意義,能夠更好地保障系統的穩定運行和及時響應問題。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/907524.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/907524.shtml
英文地址,請注明出處:http://en.pswp.cn/news/907524.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

NHANES指標推薦:CQI

文章題目&#xff1a;The impact of carbohydrate quality index on menopausal symptoms and quality of life in postmenopausal women 中文標題&#xff1a;碳水化合物質量指數對絕經后婦女更年期癥狀和生活質量的影響 發表雜志&#xff1a;BMC Womens Health 影響因子&…

【cpp-httplib】 安裝與使用

cpp-httplib 1. 介紹2. 安裝3. 類與接口3.1 httplib請求3.2 httplib響應3.3 httplib服務端3.4 httplib客戶端 4. 使用4.1 服務端4.2 客戶端 1. 介紹 C HTTP 庫&#xff08;cpp-httplib&#xff09;是一個輕量級的 C HTTP 客戶端/服務器庫&#xff0c;它提供了簡單的 API 來創建…

Electron-vite【實戰】MD 編輯器 -- 系統菜單(含菜單封裝,新建文件,打開文件,打開文件夾,保存文件,退出系統)

最終效果 整體架構 src/main/index.ts import { createMenu } from ./menu在 const mainWindow 后 // 加載菜單createMenu(mainWindow)src/main/menu.ts import { BrowserWindow, Menu, MenuItem, MenuItemConstructorOptions, dialog, shell } from electron import fs from…

【第4章 圖像與視頻】4.5 操作圖像的像素

文章目錄 前言示例-獲取和修改圖像數據圖像數據的遍歷方式圖像濾鏡負片濾鏡黑白濾鏡浮雕濾鏡filter濾鏡屬性 前言 getImageData() 與 putImageData() 這兩個方法分別用來獲取圖像的像素信息&#xff0c;以及向圖像中插入像素。與此同時&#xff0c;如果有需要&#xff0c;也可…

【Docker 從入門到實戰全攻略(一):核心概念 + 命令詳解 + 部署案例】

1. 是什么 Docker 是一個用于開發、部署和運行應用程序的開源平臺&#xff0c;它使用 容器化技術 將應用及其依賴打包成獨立的容器&#xff0c;確保應用在不同環境中一致運行。 2. Docker與虛擬機 2.1 Docker&#xff08;容器化&#xff09; 容器化是一種輕量級的虛擬化技術…

Vue:axios(POST請求)

發送 POST 請求 基本用法 axios.post(/api/login, {username: lcyyyy,password: 123456 }) .then(response > {console.log(請求成功:, response.data); }) .catch(error > {console.error(請求失敗:, error); });在 Vue 組件中使用 export default {methods: {async …

一周學會Pandas2之Python數據處理與分析-數據重塑與透視-unstack() - 解堆 (行 -> 列)

鋒哥原創的Pandas2 Python數據處理與分析 視頻教程&#xff1a; 2025版 Pandas2 Python數據處理與分析 視頻教程(無廢話版) 玩命更新中~_嗶哩嗶哩_bilibili unstack() 是 pandas 中用于數據重塑的重要方法&#xff0c;它與 stack() 互為逆操作。unstack() 的主要功能是將行索…

基于大模型預測的FicatIII-IV期股骨頭壞死綜合治療研究報告

目錄 一、引言 1.1 研究背景與目的 1.2 國內外研究現狀 1.3 研究意義和創新點 二、FicatIII-IV 期股骨頭壞死概述 2.1 疾病定義與分期 2.2 病因與病理機制 2.3 臨床癥狀與診斷方法 三、大模型預測原理與方法 3.1 大模型簡介 3.2 數據收集與預處理 3.3 模型訓練與優…

C++?多態!!!

一、引言 眾所周知&#xff0c;C有三大特性&#xff0c;它們分別是封裝、繼承和多態&#xff0c;在之前的文章中已經詳細介紹過封裝和繼承了&#xff0c;今天我們將一起學習多態相關的知識&#xff0c;如果還想了解封裝、繼承相關的知識&#xff0c;可以跳轉到以下鏈接&#xf…

electron安裝報錯處理

electron安裝報錯 解決方法&#xff1a; 修改 C:\Users\用戶名.npmrc下配置文件 添加代碼 electron_mirrorhttps://cdn.npmmirror.com/binaries/electron/ electron_builder_binaries_mirrorhttps://npmmirror.com/mirrors/electron-builder-binaries/最后代碼 registryhtt…

Windows10下使用QEMU安裝Ubuntu20.04虛擬機,并啟用硬件加速

Windows10下使用QEMU安裝Ubuntu20.04虛擬機&#xff0c;并啟用硬件加速 作者將狼才鯨創建日期2025-05-30 CSDN閱讀地址&#xff1a;Windows10下使用QEMU安裝Ubuntu20.04虛擬機&#xff0c;并啟用硬件加速 本文檔源碼地址&#xff1a;Windows10下使用QEMU安裝Ubuntu20.04虛擬機…

頂刊SCS | 基于視覺語言大模型推理分割的建筑足跡尺度功能分類, 樣本數據和代碼已開源!

論文介紹 題目&#xff1a;Visual-language reasoning segmentation (LARSE) of function-level building footprint across Yangtze River Economic Belt of China 期刊&#xff1a;Sustainable cities and society&#xff08;中科院一區TOP&#xff0c;IF10.5&#xff09;…

【軟件】navicat 官方免費版

Navicat Premium Lite https://www.navicat.com.cn/download/navicat-premium-lite

每個路由器接口,都必須分配所屬網絡內的 IP 地址,用于轉發數據包

在IP網絡中&#xff0c;主機&#xff08;Host&#xff09;和路由器接口&#xff08;Router Interface&#xff09;都需要分配網絡地址&#xff08;IP地址&#xff09;。 1. 主機&#xff08;Host&#xff09;的IP地址分配 (1) 作用 主機的IP地址用于唯一標識該設備&#xff0…

鴻蒙OSUniApp頁面切換動效實戰:打造流暢精致的轉場體驗#三方框架 #Uniapp

UniApp頁面切換動效實戰&#xff1a;打造流暢精致的轉場體驗 引言 在移動應用開發中&#xff0c;頁面切換動效不僅能提升用戶體驗&#xff0c;還能傳達應用的品質感。隨著HarmonyOS的普及&#xff0c;用戶對應用的動效體驗要求越來越高。本文將深入探討如何在UniApp中實現流暢…

Tesseract OCR 安裝與中文+英文識別實現

一、下載 https://digi.bib.uni-mannheim.de/tesseract/ 下載&#xff0c;盡量選擇時間靠前的&#xff08;識別更好些&#xff09;。符合你的運行機&#xff08;我的是windows64&#xff09; 持續點擊下一步安裝&#xff0c;安裝你認可的路徑即可&#xff0c;沒必要配置環境變…

Visual Studio 2022 發布獨立的 exe 文件

我們在用 Visual Studio 2022 寫好一個 exe 程序之后&#xff0c;如果想把這個拿到其他地方運行&#xff0c;需要把 exe 所在的文件夾一起拿過去。 編譯出來的 exe 文件需要其他幾個文件一同放在同一目錄才能運行&#xff0c;原因在于默認情況下&#xff0c;Visual Studio 是把…

Kotlin-特殊類型

文章目錄 數據類型枚舉類型匿名類和伴生對象單例類伴生對象 數據類型 聲明一個數據類非常簡單: //在class前面添加data關鍵字表示為一個數據類 data class Student(var name: String, var age: Int)數據類聲明后,編譯器會根據主構造函數中聲明的所有屬性自動為其生成以下函數…

在線博客系統【測試報告】

&#x1f552; 一. 項目背景 由于紙質筆記容易丟失&#xff0c;攜帶不變&#xff0c;為了方便自己學習的過程中記錄筆記&#xff0c;特開發了這個博客系統。這個系統后端采用 SpringBoot MyBatis SpringMVC &#xff1b;前端使用Html CSS JS&#xff1b;數據庫使用的是Mysq…

每日刷題c++

快速冪 #include <iostream> using namespace std; #define int long long int power(int a, int b, int p) {int ans 1;while (b){if (b % 2){ans * a;ans % p; // 隨時取模}a * a;a % p; // 隨時取模b / 2;}return ans; } signed main() {int a, b, p;cin >> a …