floringavrila / graphite-feeder
Graphite Feeder 是一个库,可以直接将数据发送到 Graphite 数据端口。
0.0.2
2019-09-27 13:17 UTC
Requires
- php: >=5.6.0
- nesbot/carbon: ^1.32
This package is auto-updated.
Last update: 2024-09-28 01:29:06 UTC
README
Graphite 数据喂入器是一个库,用于收集和聚合指标值,然后将数据批次直接发送到 Graphite 数据端口。该库类似于 StatsD,必须作为单例使用。请确保库的保留设置与 Graphite 服务器(storage-schemas.conf)的保留设置完全相同。
安装
composer require floringavrila/graphite-feeder
git clone https://github.com/floringavrila/graphite-feeder.git
用法
有关用法示例,请参阅用法维基。
use Gavrila\GraphiteFeeder;
...
$retentions = '15s:7d,1m:21d,15m:5y';
$connector = new GraphiteFeeder\Connector\Fsock(
'graphite.host',
'2003',
'tcp'
);
$client = new GraphiteFeeder\Client($connector, $retentions);
$data = [
new GraphiteFeeder\Entity\Data(
'test.stats.process_name.elapsed_time',
10,
time()
),
new GraphiteFeeder\Entity\Data(
'test.stats.process_name.elapsed_time',
2.5,
time()
),
];
foreach ($data as $item) {
$client->dataBuffer->add($item);
}
$written = $client->flushAllData();