Slide 20
Slide 20 text
Mackerelでがんばり具合を
可視化するコード例
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]);