Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PrometheusExporterを作ってみた+α
Search
Transnano
February 12, 2019
Technology
0
270
PrometheusExporterを作ってみた+α
2019/02/12 Fukuoka.go#13で登壇した内容です
タグ:Prometheus, golang
Transnano
February 12, 2019
Tweet
Share
More Decks by Transnano
See All by Transnano
ヤフーのデータ入出稿を支えるSRE
transnano
0
640
2019/07/11 ふくばねてす node-2 コンテナ移行におけるアレコレと使えるアレコレ(仮)
transnano
0
450
Consulって何だろう
transnano
0
120
バックエンドエンジニアから見たReact #react_fukuoka
transnano
2
130
Other Decks in Technology
See All in Technology
New Relic 1 年生の振り返りと Cloud Cost Intelligence について #NRUG
play_inc
0
230
AgentCore BrowserとClaude Codeスキルを活用した 『初手AI』を実現する業務自動化AIエージェント基盤
ruzia
7
1.4k
AWSインフルエンサーへの道 / load of AWS Influencer
whisaiyo
0
220
松尾研LLM講座2025 応用編Day3「軽量化」 講義資料
aratako
4
3k
投資戦略を量産せよ 2 - マケデコセミナー(2025/12/26)
gamella
0
300
AR Guitar: Expanding Guitar Performance from a Live House to Urban Space
ekito_station
0
150
事業の財務責任に向き合うリクルートデータプラットフォームのFinOps
recruitengineers
PRO
2
200
アラフォーおじさん、はじめてre:Inventに行く / A 40-Something Guy’s First re:Invent Adventure
kaminashi
0
140
Next.js 16の新機能 Cache Components について
sutetotanuki
0
180
AIエージェント開発と活用を加速するワークフロー自動生成への挑戦
shibuiwilliam
5
840
Connection-based OAuthから学ぶOAuth for AI Agents
flatt_security
0
360
Kiro を用いたペアプロのススメ
taikis
4
1.8k
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.3k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
170
Test your architecture with Archunit
thirion
1
2.1k
Evolving SEO for Evolving Search Engines
ryanjones
0
73
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
100
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
30
Tell your own story through comics
letsgokoyo
0
760
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
580
The Limits of Empathy - UXLibs8
cassininazir
1
190
Chasing Engaging Ingredients in Design
codingconduct
0
84
Transcript
PrometheusExporterを作っ てみた+α 2019/02/12 杉永 良太
自己紹介 杉永 良太 @transnano 普段の業務ではSRE的なことをやっ てます Go歴:初級レベルくらい • Dockerが出たとき(2013?)に ソースを読んだ
• 前職で3〜4個小さめのツール 作った • 今回のLT申し込んでからGoを 再勉強し始めた
Prometheusとは プル型の監視システム • 対象の探索 • データの取得・保管 • 集計クエリの実行 • アラート
Exporter • 対象のマシン上の状 態を収集するプログ ラム(サーバ)
Golangコミュニティでよく見る光景 発表の最後らへんに登場してくるやつ os.Exit(0)
Exit関数の説明 終了ステータス/結果コード:呼び出し元に結果を返す Ref: https://golang.org/pkg/os/#Exit
shell_exit_status_exporter シェルやプログラムの終了ステータスを監視するエクスポーター 活用例: • 終了コードに意味があるシステムの結果を知る ◦ bashで言うと、255:範囲外の終了ステータスなど ◦ HTTPステータスコードみたいに状態を示すなど •
任意のコマンド/プログラムの実行し、結果を知る ソース:Transnano / shell_exit_status_exporter - GitLab
PrometheusExporterの作り方 公式のWritingExporters - Prometheus Docsを参照 命名規則や呼び出し方などのお作法に従うこと 1. Exporterの名前には-が使えない(実行時にエラーになる a. ❎abc-exporter、⭕abc_exporter
2. Metricsの名称にも-は使えない(プログラミング言語も変数に-が使えない のと同じ理由)、prefixを付けるとわかりやすい a. ❎abc-cpu-num、⭕abc_cpu_usage、abc_memory_usage 3. 動作portはある程度Default-port-allocationsで決まっているが変更 できるように作り込んでおくと良い a. $ ./shell-exit-status-exporter -web.listen-address=”:9121”
まとめ 1. 外部コマンドの呼び出しも簡単 a. Javaとか多言語よりもシームレスに呼び出せている気がする 2. お作法に従えばExporterもすぐ出来る/従わないと動かない 3. $GOPATH/srcにghq.rootを指定するとghq+pecoで幸せになれる 4.
パッケージ管理がわからない
os.Exit(255)
sre-fukuoka.connpassを企画中 3月上旬開催予定 福岡のSREやDevOpsに興味がある人が集まって意見交換できる場 Comming Soon!!!
os.Exit(0)