PHPackages                             metrics-tracker/watchlog - 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. metrics-tracker/watchlog

ActiveLibrary

metrics-tracker/watchlog
========================

A PHP package for sending metrics.

2.0.0(5mo ago)012MITPHPCI passing

Since Jun 5Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/watchlogserver/watchlog-php)[ Packagist](https://packagist.org/packages/metrics-tracker/watchlog)[ RSS](/packages/metrics-tracker-watchlog/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (8)Used By (0)

Watchlog PHP Client
===================

[](#watchlog-php-client)

🔗 **Website**:

A lightweight PHP client for sending custom metrics to the [Watchlog](https://watchlog.io/) monitoring platform.

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require metrics-tracker/watchlog
```

Basic Usage
-----------

[](#basic-usage)

```
use MetricsTracker\Watchlog;

$watchlog = new Watchlog();

// Increment a metric (default is 1)
$watchlog->increment('page_views');
$watchlog->increment('page_views', 5);

// Decrement a metric (default is 1)
$watchlog->decrement('active_users');
$watchlog->decrement('active_users', 2);

// Set a gauge value
$watchlog->gauge('memory_usage', 512);

// Set a percentage value (0-100)
$watchlog->percentage('cpu_usage', 75);

// Set a system byte value
$watchlog->systembyte('disk_space', 1024000);
```

Docker Setup
------------

[](#docker-setup)

When running your PHP app in Docker, you can specify the agent URL explicitly:

```
use MetricsTracker\Watchlog;

// Create client with explicit agent URL for Docker
$watchlog = new Watchlog('http://watchlog-agent:3774');

$watchlog->increment('page_views', 1);
```

**Docker Compose Example:**

```
version: '3.8'

services:
  watchlog-agent:
    image: watchlog/agent:latest
    container_name: watchlog-agent
    ports:
      - "3774:3774"
    environment:
      - WATCHLOG_APIKEY=your-api-key
      - WATCHLOG_SERVER=https://log.watchlog.ir
    networks:
      - app-network

  php-app:
    build: .
    container_name: php-app
    ports:
      - "80:80"
    depends_on:
      - watchlog-agent
    networks:
      - app-network

networks:
  app-network:
    driver: bridge
```

**Docker Run Example:**

```
# 1. Create network
docker network create app-network

# 2. Run Watchlog Agent
docker run -d \
  --name watchlog-agent \
  --network app-network \
  -p 3774:3774 \
  -e WATCHLOG_APIKEY="your-api-key" \
  -e WATCHLOG_SERVER="https://log.watchlog.ir" \
  watchlog/agent:latest

# 3. Run PHP app (make sure your code uses new Watchlog('http://watchlog-agent:3774'))
docker run -d \
  --name php-app \
  --network app-network \
  -p 80:80 \
  my-php-app
```

Environment Detection
---------------------

[](#environment-detection)

The package automatically detects the runtime environment:

- **Local / non-K8s**: `http://127.0.0.1:3774`
- **Kubernetes**: `http://watchlog-node-agent.monitoring.svc.cluster.local:3774`

**Manual Override:** You can override the endpoint by passing `agentUrl` parameter to the constructor:

```
$watchlog = new Watchlog('http://watchlog-agent:3774'); // Custom agent URL
```

**Important Notes:**

- When using Docker, use the container name as the hostname (e.g., `watchlog-agent`)
- Both containers must be on the same Docker network
- The agent must be running before your app starts
- If `agentUrl` is not provided, auto-detection will be used (local or Kubernetes)
- All operations are asynchronous and fail-safe

License
-------

[](#license)

MIT © Watchlog

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance70

Regular maintenance activity

Popularity5

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~89 days

Recently: every ~34 days

Total

7

Last Release

169d ago

Major Versions

1.1.8 → 2.0.02025-11-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/7cec97900c369546bd173d510f8c6742c449df03b71b3dbf1c8a78ec2953defb?d=identicon)[rexi1r](/maintainers/rexi1r)

---

Top Contributors

[![mohammadnajm](https://avatars.githubusercontent.com/u/45530873?v=4)](https://github.com/mohammadnajm "mohammadnajm (4 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (4 commits)")[![mehdinajm](https://avatars.githubusercontent.com/u/88393417?v=4)](https://github.com/mehdinajm "mehdinajm (3 commits)")

### Embed Badge

![Health badge](/badges/metrics-tracker-watchlog/health.svg)

```
[![Health](https://phpackages.com/badges/metrics-tracker-watchlog/health.svg)](https://phpackages.com/packages/metrics-tracker-watchlog)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k20](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
