Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PrometheusExporterを作ってみた+α
Search
Transnano
February 12, 2019
Technology
0
260
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
620
2019/07/11 ふくばねてす node-2 コンテナ移行におけるアレコレと使えるアレコレ(仮)
transnano
0
410
Consulって何だろう
transnano
0
120
バックエンドエンジニアから見たReact #react_fukuoka
transnano
2
120
Other Decks in Technology
See All in Technology
本当に使える?AutoUpgrade の新機能を実践検証してみた
oracle4engineer
PRO
1
140
rubygem開発で鍛える設計力
joker1007
2
190
Agentic Workflowという選択肢を考える
tkikuchi1002
1
490
5min GuardDuty Extended Threat Detection EKS
takakuni
0
130
標準技術と独自システムで作る「つらくない」SaaS アカウント管理 / Effortless SaaS Account Management with Standard Technologies & Custom Systems
yuyatakeyama
3
1.2k
Clineを含めたAIエージェントを 大規模組織に導入し、投資対効果を考える / Introducing AI agents into your organization
i35_267
4
1.5k
_第3回__AIxIoTビジネス共創ラボ紹介資料_20250617.pdf
iotcomjpadmin
0
150
ハノーバーメッセ2025座談会.pdf
iotcomjpadmin
0
160
Postman AI エージェントビルダー最新情報
nagix
0
110
LinkX_GitHubを基点にした_AI時代のプロジェクトマネジメント.pdf
iotcomjpadmin
0
170
MySQL5.6から8.4へ 戦いの記録
kyoshidaxx
1
190
A2Aのクライアントを自作する
rynsuke
1
170
Featured
See All Featured
Optimizing for Happiness
mojombo
379
70k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
How to Ace a Technical Interview
jacobian
277
23k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.9k
A better future with KSS
kneath
239
17k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
Site-Speed That Sticks
csswizardry
10
660
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
228
22k
[RailsConf 2023] Rails as a piece of cake
palkan
55
5.6k
We Have a Design System, Now What?
morganepeng
53
7.7k
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)