PHPackages                             maltertech/betterstack-telemetry - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. maltertech/betterstack-telemetry

ActiveLibrary[HTTP &amp; Networking](/categories/http)

maltertech/betterstack-telemetry
================================

PHP client for BetterStack Telemetry API

v1.0.2(3mo ago)01.7k↑18.3%MITPHPPHP &gt;=8.3

Since Dec 24Pushed 3mo agoCompare

[ Source](https://github.com/maltertech/betterstack-telemetry)[ Packagist](https://packagist.org/packages/maltertech/betterstack-telemetry)[ RSS](/packages/maltertech-betterstack-telemetry/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (2)Versions (4)Used By (0)

BetterStack Telemetry for AWS CloudWatch
========================================

[](#betterstack-telemetry-for-aws-cloudwatch)

A lightweight, zero-dependency PHP library designed to forward **AWS CloudWatch Logs** directly to **BetterStack Telemetry (Logtail)**.

This package handles the specific format of AWS Lambda log subscription filters:

1. **Decodes** Base64 payload.
2. **Decompresses** Gzip data.
3. **Parses** JSON log events.
4. **Filters** standard Lambda noise (start/end requests).
5. **Ships** structured logs to BetterStack.

Requirements
------------

[](#requirements)

- PHP 8.3+
- `ext-json`
- `ext-zlib`
- `php-curl-class/php-curl-class`

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

[](#installation)

Install the package via Composer:

```
composer require maltertech/betterstack-telemetry
```

Usage
-----

[](#usage)

This library is designed to be used inside an AWS Lambda function (or any PHP application receiving raw CloudWatch log streams).

### 1. Initialization

[](#1-initialization)

Initialize the forwarder with your BetterStack credentials. Ideally, do this in your application's Service Provider or Dependency Injection container.

```
use MalterTech\BetterStack\CloudWatchForwarder;

$logger = new CloudWatchForwarder(
    sourceToken:  'BETTERSTACK_TOKEN',      // Your Source Token from BetterStack
    ingestionUrl: 'https://in.logs.betterstack.com', // The Ingestion URL
    sourceName:   'Client-API-01'                    // Identifier for this logs source
);
```

### 2. Processing Events

[](#2-processing-events)

Pass the raw AWS event payload to the `push` method. The library will automatically detect if the payload contains compressed `awslogs` data and process it.

```
// Inside your Lambda Handler or Controller
public function handle(array $event)
{
    // ... your application logic ...

    // Forward logs to BetterStack
    $logger->push($event);
}
```

How it Works
------------

[](#how-it-works)

When AWS CloudWatch streams logs to a Lambda function, it sends them in a compressed format: `{ "awslogs": { "data": "H4sIAAAAAAAA/..." } }`

The `CloudWatchForwarder` performs the following steps:

1. **Extraction:** target the `['awslogs']['data']` key.
2. **Decompression:** `base64_decode` -&gt; `gzdecode`.
3. **Parsing:** Iterates through `logEvents`.
4. **Cleaning:** Skips strictly internal Lambda messages (like `RequestId: ...`) to save quota.
5. **Formatting:** Checks if the log message itself is JSON (e.g., from API Gateway) and parses it into a structured object; otherwise, treats it as a string.

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance79

Regular maintenance activity

Popularity21

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~41 days

Total

3

Last Release

109d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b347e1360b09ecf642a1edb296f07dae2467b2f4fefb9dff432f390d9a6d30c?d=identicon)[zmalter99](/maintainers/zmalter99)

---

Top Contributors

[![zmalter99](https://avatars.githubusercontent.com/u/47525124?v=4)](https://github.com/zmalter99 "zmalter99 (4 commits)")

### Embed Badge

![Health badge](/badges/maltertech-betterstack-telemetry/health.svg)

```
[![Health](https://phpackages.com/badges/maltertech-betterstack-telemetry/health.svg)](https://phpackages.com/packages/maltertech-betterstack-telemetry)
```

###  Alternatives

[labs64/netlicensingclient-php

PHP wrapper for Labs64 NetLicensing RESTful API

1550.9k1](/packages/labs64-netlicensingclient-php)[megacreativo/cedulave-api

CedulaVE API permite consultar datos personales de habitantes de Venezuela inscritos en el CNE mediante su Cédula de Identidad.

261.4k](/packages/megacreativo-cedulave-api)

PHPackages © 2026

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