Skip to content

Commit 694c8f1

Browse files
authored
Merge pull request #2070 from brefphp/rework-monitoring-docs
Rewrite monitoring docs
2 parents abe4e0e + 52e0fde commit 694c8f1

10 files changed

Lines changed: 100 additions & 35 deletions

File tree

docs/monitoring.mdx

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import Image from 'next/image';
2+
import cloudXrayTrace from './monitoring/cloud-xray-trace.png';
3+
import cloudXrayFiltersGeneral from './monitoring/cloud-xray-filters-general.png';
4+
import cloudXrayFiltersAnnotations from './monitoring/cloud-xray-filters-annotations.png';
5+
import cloudOverview from './monitoring/cloud-overview.png';
6+
import cloudLogs from './monitoring/cloud-logs.png';
7+
8+
# Monitoring
9+
10+
By default, AWS Lambda publishes PHP logs and metrics to [AWS CloudWatch](https://aws.amazon.com/cloudwatch/). These include HTTP response times, code execution duration, error rates, and more.
11+
12+
Here is a summary of recommended tools for monitoring Bref applications:
13+
14+
- **Logs and metrics**: CloudWatch (built-in), [Bref Cloud](/cloud)
15+
- **Error tracking**: [Sentry](https://sentry.io) and similar services
16+
- **Performance tracing**: [Bref Cloud](/cloud) with [X-Ray](/xray)
17+
18+
Let's dive into the details of each of them.
19+
20+
## Sentry
21+
22+
[Sentry](https://sentry.io) is a popular error tracking service. It works well out of the box with Bref for HTTP applications: install the [Sentry SDK for PHP](https://docs.sentry.io/platforms/php/) (or the [Laravel](https://docs.sentry.io/platforms/php/guides/laravel/) or [Symfony](https://docs.sentry.io/platforms/php/guides/symfony/) integrations) and errors will be tracked automatically.
23+
24+
For more advanced use cases, such as tracking Lambda errors outside of PHP-FPM (timeouts, oversized responses…), monitoring event-driven handlers (SQS, EventBridge, S3…), or tracking cold starts and AWS SDK calls, the [Bref Sentry package](/sentry) extends Sentry's capabilities for AWS Lambda. It is available as a [separate license](/sentry).
25+
26+
## Bref Cloud
27+
28+
[Bref Cloud](/cloud) provides an all-in-one monitoring experience for serverless PHP applications:
29+
30+
<Image className="mt-3 rounded-lg shadow-md border" src={cloudOverview} alt="Bref Cloud application overview" />
31+
32+
- **Logs**: view and search CloudWatch logs in a simplified UI.
33+
34+
<Image className="mt-3 rounded-lg shadow-md border" src={cloudLogs} alt="Log viewer in Bref Cloud" />
35+
36+
- **Metrics**: monitor Lambda invocations, duration, errors, and more.
37+
- **Traces**: visualize X-Ray traces to understand the performance of your application, including database queries, HTTP calls, and AWS SDK calls.
38+
39+
<Image className="mt-3 rounded-lg shadow-md border" src={cloudXrayTrace} alt="X-Ray trace in Bref Cloud" />
40+
41+
With the [Bref X-Ray](/xray) package, traces are enriched with annotations that you can use to filter and search. For example, you can filter traces by specific controller, route, CLI command, or job class:
42+
43+
<div className="flex gap-4 mt-3 items-start">
44+
<Image className="rounded-lg shadow-md border h-auto" style={{maxHeight: 350, width: 'auto'}} src={cloudXrayFiltersGeneral} alt="X-Ray trace filters in Bref Cloud" />
45+
<Image className="rounded-lg shadow-md border h-auto" style={{maxHeight: 350, width: 'auto'}} src={cloudXrayFiltersAnnotations} alt="X-Ray trace annotation filters in Bref Cloud" />
46+
</div>
47+
48+
Bref Cloud users get a **free [Bref X-Ray](/xray) license** included in their plan to enable performance tracing. To activate it, contact support via [bref.cloud/support](https://bref.cloud/support) or [Slack](https://bref.sh/slack).
49+
50+
[Learn more about Bref Cloud](/cloud).
51+
52+
## X-Ray
53+
54+
[AWS X-Ray](https://aws.amazon.com/xray/) provides distributed tracing for Lambda applications. The [Bref X-Ray package](/xray) integrates X-Ray with PHP, tracking cold starts, database queries, HTTP calls, AWS SDK calls, and more. It supports both Laravel and Symfony.
55+
56+
The package can be used with or without Bref Cloud. Bref Cloud users get a free license (see above), while others can [purchase a standalone license](/xray).
57+
58+
## Sentry Lambda package
59+
60+
As mentioned above, the standard Sentry SDK works great for HTTP applications. The [Bref Sentry package](/sentry) goes further by adding Lambda-specific capabilities: tracking errors outside of PHP-FPM, monitoring event-driven handlers, and tracking cold starts.
61+
62+
The package can be used with or without Bref Cloud. It is available as a [standalone license](/sentry).
63+
64+
## Bref Dashboard
65+
66+
The [Bref Dashboard](https://dashboard.bref.sh/?ref=bref) is an alternative for projects that do not use Bref Cloud. It fetches data from AWS CloudWatch and provides a simple UI for logs and metrics. It requires no setup in AWS and can be used straight away.
67+
68+
[![Bref Dashboard](./monitoring/bref-dashboard.png)](https://dashboard.bref.sh/?ref=bref)
69+
70+
## Tideways
71+
72+
[Tideways](https://tideways.com/?ref=bref) is a PHP-specific monitoring and profiling tool that can be used with Bref. It requires setting up a daemon on an EC2 instance in a VPC.
73+
74+
[Learn more about using Tideways with Bref](./monitoring/tideways.md).

docs/monitoring/_meta.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"tideways": {
3+
"display": "hidden"
4+
}
5+
}

docs/monitoring/cloud-logs.png

547 KB
Loading

docs/monitoring/cloud-overview.png

390 KB
Loading
69.1 KB
Loading
42.6 KB
Loading
511 KB
Loading
Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,4 @@
1-
# Monitoring
2-
3-
By default, AWS Lambda publishes all logs and general metrics (HTTP response time, code execution duration, etc.) to AWS CloudWatch.
4-
5-
It is possible to view these logs and metrics directly in the [AWS console](https://us-east-1.console.aws.amazon.com/cloudwatch/home?region=us-east-1). However, the CloudWatch UI can be complex and overwhelming.
6-
7-
As an alternative, we can use [Bref Cloud](/cloud) or the [Bref Dashboard](https://dashboard.bref.sh/?ref=bref) to view these logs and metrics. It provides a simpler UI designed for serverless PHP applications.
8-
9-
For advanced metrics and profiling, we can use [Tideways](https://tideways.com/?ref=bref), or [Sentry's performance monitoring](/sentry). Note that [Serverless.com's Dashboard](https://www.serverless.com/) is not compatible with PHP.
10-
11-
To summarize:
12-
13-
- **General monitoring**: [Bref Cloud](/cloud), CloudWatch, or [Bref Dashboard](https://dashboard.bref.sh/?ref=bref)
14-
- **Advanced monitoring and profiling**: [Tideways](https://tideways.com/?ref=bref), [Sentry](/sentry)
15-
16-
## Bref Cloud
17-
18-
[Bref Cloud](/cloud) is an all-in-one platform for serverless PHP applications. It provides a simple UI to view logs, metrics, and errors, and it is designed specifically for PHP applications running on AWS Lambda.
19-
20-
[Learn more about Bref Cloud](/cloud).
21-
22-
## Bref Dashboard
23-
24-
As mentioned above, the [Bref Dashboard](https://dashboard.bref.sh/?ref=bref) fetches data from AWS CloudWatch (which is published by default by all serverless applications). As such, it requires no setup in AWS and can be used straight away.
25-
26-
[![Bref Dashboard](./monitoring/bref-dashboard.png)](https://dashboard.bref.sh/?ref=bref)
27-
28-
## Tideways
29-
30-
> Disclaimer: Tideways is a Bref sponsor ❤️
1+
# Monitoring with Tideways
312

323
To use [Tideways](https://tideways.com/?ref=bref) with Bref, we first need to [create a Tideways account](https://app.tideways.io/register/).
334

@@ -38,17 +9,17 @@ Next, we will need to set up two pieces:
389

3910
Indeed, the PHP extension runs in the same process as the PHP application and collects traces and advanced metrics. It then sends this data to a Tideways daemon, that will collect it and forward it to tideways.com. That ensures the PHP extension does not add latency to the PHP application.
4011

41-
![](./monitoring/tideways-schema.svg)
12+
![](./tideways-schema.svg)
4213

4314
The connexion between the PHP extension and the daemon needs to be secured. This is why the PHP lambda and the EC2 instance need to run in a VPC (virtual private network), and the EC2 instance should only be reachable from inside the VPC.
4415

45-
### Complete example
16+
## Complete example
4617

4718
The sections below describe how to set up the daemon and PHP extension manually.
4819

4920
Alernatively, you can have a look at a complete and deployable example: [github.com/tideways/bref-tideways-example](https://github.com/tideways/bref-tideways-example). In this example, we deploy the PHP application, the VPC and the daemon in one command via `serverless.yml`.
5021

51-
### Setting up the daemon
22+
## Setting up the daemon
5223

5324
Assuming we already have a VPC set up (the [serverless-vpc-plugin](https://github.com/smoketurner/serverless-vpc-plugin) is a good solution to create one), the daemon must be started in the VPC.
5425

@@ -73,7 +44,7 @@ Assuming we already have a VPC set up (the [serverless-vpc-plugin](https://githu
7344

7445
Once the daemon has started, copy its "Private IP DNS name", we will use it to configure the PHP application.
7546

76-
### Setting up the PHP application
47+
## Setting up the PHP application
7748

7849
First, let's install the Tideways PHP extension (it is distributed via the Bref extra extensions):
7950

@@ -125,7 +96,7 @@ provider:
12596
```
12697
12798
> **Note**:
128-
>
99+
>
129100
> The `TIDEWAYS_CONNECTION` variable should contain the "Private IP DNS name" of the Tideways daemon (for example `tcp://ip-172-31-4-74.eu-west-1.compute.internal:9135`). This is the value you retrieved in the previous section.
130101

131102
Don't forget to redeploy the application:

website/src/pages/cloud/features.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ const sections = [
8484
cloud: true,
8585
}
8686
},
87+
{ name: 'X-Ray tracing', tiers: {
88+
bref: {
89+
title: false,
90+
description: 'AWS CloudWatch (advanced) <br> + extra <a class="underline" href="/xray">Bref X-Ray</a> license',
91+
},
92+
cloud: {
93+
title: true,
94+
description: 'Trace explorer optimized for PHP apps. <br> No extra license needed.',
95+
},
96+
}
97+
},
8798
{ name: 'Queue jobs management', tiers: { bref: false, cloud: true } },
8899
{ name: 'Secrets management', tiers: {
89100
bref: {

website/src/pages/xray/docs.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ This package provides an advanced integration between Bref applications and [AWS
1212

1313
Check out the documentation below for screenshots and more details. View the [changelog](/xray/changelog) for the latest updates and releases.
1414

15+
<Callout type="info">
16+
**Bref Cloud users** get a free X-Ray license included in their plan. You can view traces directly in the [Bref Cloud dashboard](/docs/monitoring#bref-cloud). To activate your free license, contact support via [bref.cloud/support](https://bref.cloud/support) or [Slack](https://bref.sh/slack).
17+
</Callout>
18+
1519
## Installation
1620

1721
### 1. Enable Packagist.com

0 commit comments

Comments
 (0)