Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
mackerel-client-php
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Takuya Arita
January 26, 2017
Technology
5.5k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
mackerel-client-php
Mackerel Meetup #9のLT資料です
Takuya Arita
January 26, 2017
More Decks by Takuya Arita
See All by Takuya Arita
Hosted Redash の EOL と移行ツール redash-migrate / You should know about Hosted Redash EOL and redash-migrate
ariarijp
0
3.4k
Redash で踏み出す BI 導入はじめの一歩 / DataEngineeringStudy Redash
ariarijp
1
2.8k
Redash のいま / Redash in 2021
ariarijp
2
1.2k
Redash 導入・運用を4年ぐらいやって変わったこと・変わらなかったこと / Changed and unchanged things with Redash and me
ariarijp
0
1.4k
5年前の自分に伝えたい広告 API 周辺の歩き方 / SOT Tech Night vol.1
ariarijp
1
550
使われていない、を知る / How do we know unused things in the real world?
ariarijp
0
490
MULTI_ORG について / What is MULTI_ORG in Redash
ariarijp
1
3.9k
あらためて振り返る Redash の使いどころ / Why I strongly recommend Redash
ariarijp
2
1.3k
PHP Data Structures
ariarijp
1
580
Other Decks in Technology
See All in Technology
Slack上でインフラをトラブルシュートする! Agentic Platform Engineeringの第一歩
teru0x1
1
330
TinyGo 開発サイクルを高速化する:Go で作るエミュレータ入門
zozotech
PRO
1
600
AIに丸投げしないトイル削減 / Eliminating Toil Without Leaving It All to AI
kohbis
4
1.1k
[2026-09-11]SREは誰のもの?運用エンジニアが始める 「SRE領域への越境」とチームの進化の軌跡 〜Road to NEXT CRE
tosite
0
120
Driving AI Adoption Using In-House GPUs to Serve Qwen
po3rin
2
480
2026_devsumi_ozono.pdf
o3
2
330
Amazon Quick on DesktopがIAM Identity Centerで動かない理由
yukiogawa
0
150
2026-09-11 【Snowflake World Tour Tokyo 2026】Snowflakeを起点に、AI Agentが自律稼働し続ける未来へ / Driving AI Agents with Snowflake
civitaspo
0
290
AI時代に顧客へ最速で価値を 届けるための試行錯誤 〜「AI × マネジメント」領域におけるmentoのケース〜
posterkeisuke
0
110
Multica × 長期記憶:40個のミニプロジェクト管理
eiei114
1
240
Redmine 7.0で私が開発した新機能の狙いと背景
vividtone
1
160
omasushiというライブラリを作った
polidog
PRO
0
190
Featured
See All Featured
Un-Boring Meetings
codingconduct
0
410
Mind Mapping
helmedeiros
1
350
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
520
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
690
Heart Work Chapter 1 - Part 1
lfama
PRO
9
36k
Designing for Performance
lara
611
70k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
490
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
470
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.1k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
440
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.5k
Transcript
mackerel-client-php @ariarijp
自己紹介 • @ariarijp(Takuya Arita) • 株式会社ココラブル ソフトウェアエンジニア • 普段はPHPを書いたりしていますが、インフラも扱 います
• mackerel-agent-pluginsにプルリクエストを送った ことがあります
Mackerelといえば
None
可視化がうれしい
Mackerelに メトリクスを送ろう
Mackerelにメトリクスを 送る方法 • mackerel-agentやプラグインを使う • mkrを使う • 各言語向けのクライアントライブラリを使う • Mackerel
APIを使う
Mackerelにメトリクスを 送る方法 • mackerel-agentやプラグインを使う • mkrを使う • 各言語向けのクライアントライブラリを使う • Mackerel
APIを使う
Mackerelの クライアントライブラリ • mackerelio/mackerel-client-go • mackerelio/mackerel-client-ruby • itchyny/mackerel-client-hs • heavenshell/py-mackerel-client
• pepabo/mackerel-rb • muddydixon/node-mackerel • ariarijp/mackerel-client-php
Mackerelの クライアントライブラリ • mackerelio/mackerel-client-go • mackerelio/mackerel-client-ruby • itchyny/mackerel-client-hs • heavenshell/py-mackerel-client
• pepabo/mackerel-rb • muddydixon/node-mackerel • ariarijp/mackerel-client-php
PHP版のクライアントを 作ってみました
None
None
導入 composer require ariarijp/mackerel-client:dev-master (2017/01/26ݱࡏ)
使ってみる (READMEに記載) <?php require __DIR__ . '/vendor/autoload.php'; $client
= new \Mackerel\Client([ 'mackerel_api_key' => 'YOUR_MACKEREL_API_KEY_HERE', ]); $host = $client->getHost('HOST_ID');
使ってみる (メトリクスを送ってみる) <?php require __DIR__ . '/vendor/autoload.php'; $client
= new \Mackerel\Client([ 'mackerel_api_key' => 'YOUR_MACKEREL_API_KEY_HERE', ]); $host = $client->getHost('HOST_ID'); $metric = [ 'hostId' => $host->id, 'time' => time(), 'name' => 'metrics.meetup.random', 'value' => mt_rand(1, 6), ]; var_dump($metric); $client->postMetrics([$metric]); ※公式ドキュメント:ホストのカスタムメトリックを投稿するを参考にしました
PHPerも気軽に メトリクスを送れる! • アプリケーション固有のメトリクスを送る • バッチ処理などの実行時間を送る • 外部APIのレスポンスタイムやエラー率を送る
メトリクスさえ送れば あとはMackerelが 可視化も監視もしてくれる
(小ネタ) Mackerelでがんばり具合を可視化する • SlackのUser Presence APIを使用 • レスポンスにはメンバー一覧とその状態が含まれる • アクティブなユーザーの数を拾い、mackerel-
client-phpを使ったPHPスクリプトでMackerelに送 る
Mackerelでがんばり具合を 可視化するコード例 <?php require __DIR__ . '/vendor/autoload.php'; function
getActiveUsersCount() { $client = new GuzzleHttp\Client(); $resp = $client->get('https://slack.com/api/users.list', [ 'query' => [ 'token' => ‘YOUR_SLACK_TOKEN’, 'presence' => '1', ], ]); $presence = json_decode($resp->getBody()->getContents()); return count(array_filter($presence->members, function ($m) { return $m->presence == 'active'; })); } $client = new \Mackerel\Client([ 'mackerel_api_key' => 'YOUR_MACKEREL_API_KEY_HERE', ]); $host = $client->getHost('HOST_ID'); $metric = [ 'hostId' => $host->id, 'time' => time(), 'name' => 'metrics.slack.active', 'value' => getActiveUsersCount(), ]; var_dump($metric); $client->postMetrics([$metric]);
Mackerelでがんばり具合を 可視化した例
Mackerelでがんばり具合を 可視化した例 やる気が急激に減っているのではなく 今日は18時から全社定例がありました activeだけに絞るの忘れてた またやる気が減っているように見えますが 月例の全社飲み会が始まったのだと思います Meetup会場に移動中
PHP x Mackerel便利 (だと思う)
PHPerのみなさまにおかれましては mackerel-client-phpの導入もご検討ください