PHPackages                             yuanlj-tea/metric - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. yuanlj-tea/metric

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yuanlj-tea/metric
=================

metric component

v1.0.6(3y ago)198MITPHPPHP &gt;=7.1

Since Dec 6Pushed 3y ago1 watchersCompare

[ Source](https://github.com/yuanlj-tea/metric)[ Packagist](https://packagist.org/packages/yuanlj-tea/metric)[ RSS](/packages/yuanlj-tea-metric/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (8)Used By (0)

### Installation

[](#installation)

Use composer:

```
composer require yuanlj-tea/metric
```

### Usage

[](#usage)

配置文件

```
配置文件模板路径，复制一份到自己的项目：
/publish/metric.php

配置文件内容：
    'default' => 'prometheus',  // 配置使用的适配器
    'default_metric_interval' => 5,
    'metric' => [
        'prometheus' => [
            'driver' => \Metric\Adapter\Prometheus\MetricFactory::class,		// prometheus使用的class
            'mode' => \Metric\Adapter\Prometheus\Constants::SCRAPE_MODE,		// 模式，抓取模式或主动推送模式
            'storage_adapter' => 'redis',		// 数据存储方式
            'namespace' => 'app-name',		// config namespace
            'scrape_host' => '0.0.0.0',		// 抓取模式时的host
            'scrape_port' => '9502',		// 抓取模式时的port
            'scrape_path' => '/metrics',		// 抓取模式时的请求接口
            'push_host' => '0.0.0.0',		// 主动推送模式的host
            'push_port' => '9091',		// 主动推送模式的port
            'push_interval' => 5,		// 主动推送模式的间隔时间
        ],
    ],
    'redis' => [		// 使用redis存储时的redis相关配置
        'host' => '127.0.0.1',
        'port' => 6379,
        'password' => 123456,
        'timeout' => 1, // in seconds
        'read_timeout' => '10', // in seconds
        'persistent_connections' => false
    ],

```

useage demo

```
