Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
子育てで想像してなかった「見えないダメージ」 / Unforeseen "hidden burdens" of raising children.
pauli
2
320
Identity Management for Agentic AI 解説
fujie
0
460
Agent Skillsがハーネスの垣根を超える日
gotalab555
6
4.2k
AWS re:Invent 2025~初参加の成果と学び~
kubomasataka
0
190
ペアーズにおけるAIエージェント 基盤とText to SQLツールの紹介
hisamouna
2
1.6k
Strands AgentsとNova 2 SonicでS2Sを実践してみた
yama3133
1
1.8k
Entity Framework Core におけるIN句クエリ最適化について
htkym
0
120
Connection-based OAuthから学ぶOAuth for AI Agents
flatt_security
0
360
事業の財務責任に向き合うリクルートデータプラットフォームのFinOps
recruitengineers
PRO
2
200
AI駆動開発ライフサイクル(AI-DLC)の始め方
ryansbcho79
0
160
ActiveJobUpdates
igaiga
1
310
Claude Codeを使った情報整理術
knishioka
4
1.8k
Featured
See All Featured
Paper Plane
katiecoart
PRO
0
44k
Building Adaptive Systems
keathley
44
2.9k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
0
170
Music & Morning Musume
bryan
46
7k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
90
SEO for Brand Visibility & Recognition
aleyda
0
4.1k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.7k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Building AI with AI
inesmontani
PRO
1
570
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
0
45
Applied NLP in the Age of Generative AI
inesmontani
PRO
3
2k
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)