You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cloud.mdx
+33-4Lines changed: 33 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,42 @@ import Image from 'next/image';
8
8
9
9
# Bref Cloud documentation
10
10
11
-
Bref Cloud makes it easy to deploy and monitor serverless PHP applications on AWS Lambda. Learn more about it [on the Bref Cloud homepage](https://bref.sh/cloud).
11
+
[Bref Cloud](/cloud) is the service that complements the open-source Bref project. It deploys, monitors and operates serverless PHP applications on AWS Lambda, in your own AWS account, without the AWS complexity.
12
12
13
-
To get started, [create a free Bref Cloud account](https://bref.cloud/register).
14
-
15
-
Bref Cloud is a service that complements the open-source Bref project. It connects to all your AWS accounts to simplify permissions and access management, and provides a dashboard to manage your serverless applications.
13
+
To get started, [create a Bref Cloud account](https://bref.cloud/register). There is a free plan for personal projects, and paid plans come with a free trial. See the [pricing](/cloud#pricing).
16
14
17
15
<Cardsnum={2}>
18
16
<Cards.Cardicon={<Imagesrc={brefIcon}className="size-6" />}title="Learn more about Bref Cloud"href="/cloud" />
19
17
<Cards.Cardicon={<Imagesrc={brefIcon}className="size-6" />}arrow={true}title="Get started with Bref Cloud"href="https://bref.cloud/register" />
20
18
</Cards>
19
+
20
+
## What Bref Cloud does
21
+
22
+
### Deploy
23
+
24
+
-**One command**: `bref deploy` from your machine or [from GitHub Actions](./cloud-deploy.mdx). No AWS credentials to create, distribute or rotate: Bref Cloud generates [short-lived credentials](./cloud-security.mdx) for every deployment.
25
+
-**Databases and networks**: create MySQL or PostgreSQL databases (fixed instances, or serverless databases that scale and pause on their own) and private networks in a few clicks.
26
+
-**Environments**: manage dev, staging and production across AWS accounts and regions from one dashboard, with the history of every deployment.
27
+
28
+
### Monitor
29
+
30
+
-**Overview**: a diagram of each environment's architecture with live metrics on every component.
31
+
-**Logs**: search logs or tail them in real time.
32
+
-**Metrics**: Lambda invocations, concurrency, duration and errors, API Gateway, queues and dead-letter queues.
33
+
-**Traces**: a trace explorer optimized for PHP applications, with a free [Bref X-Ray](/xray) license included. See database queries, HTTP calls and AWS calls inside each invocation, and filter traces by route, job, command, cold start, or your own annotations, over up to 30 days.
34
+
-**Performance**: the slowest database queries, the latency of every route, and the slowest jobs of your application, computed from the last 30 days of traces.
35
+
-**Health checks**: verify that the database, the cache and the Lambda configuration of a deployed application are healthy (Laravel only for now).
36
+
37
+
[Learn more about monitoring with Bref Cloud](/docs/monitoring#bref-cloud).
38
+
39
+
### Operate
40
+
41
+
-**Queues**: watch queues and dead-letter queues, and retry, delete or flush failed Laravel jobs.
42
+
-**Commands**: run console commands (Artisan, Symfony console…) on a deployed environment from the dashboard.
43
+
-**Secrets**: create and manage secrets for all your applications.
44
+
-**Files**: browse, upload, rename and delete files in S3 buckets.
45
+
46
+
### Team and security
47
+
48
+
-**Team members**: invite teammates with read-only, write or admin access. They never need AWS access.
49
+
-**AWS access**: Bref Cloud connects to your AWS accounts through IAM roles and temporary credentials, never long-lived access keys. [Learn more](./cloud-security.mdx).
@@ -17,7 +18,7 @@ Here is a summary of recommended tools for monitoring Bref applications:
17
18
18
19
-**Logs and metrics**: CloudWatch (built-in), [Bref Cloud](/cloud)
19
20
-**Error tracking**: [Sentry](https://sentry.io) and similar services
20
-
-**Performance tracing**: [Bref Cloud](/cloud) with [X-Ray](/xray)
21
+
-**Tracing and performance insights**: [Bref Cloud](/cloud) with [X-Ray](/xray)
21
22
22
23
Let's dive into the details of each of them.
23
24
@@ -29,27 +30,59 @@ For more advanced use cases, such as tracking Lambda errors outside of PHP-FPM (
29
30
30
31
## Bref Cloud
31
32
32
-
[Bref Cloud](/cloud) provides an all-in-one monitoring experience for serverless PHP applications:
33
+
[Bref Cloud](/cloud) monitors serverless PHP applications. It reads logs, metrics and traces from your AWS account. There is no agent to install.
34
+
35
+
### Overview
36
+
37
+
The overview page shows a diagram of the environment: Lambda functions, API Gateway, CloudFront, SQS queues, S3 buckets and databases. Each component shows live metrics: requests, invocations, errors, queue size, storage.
-**Logs**: view and search CloudWatch logs in a simplified UI.
41
+
### Logs
42
+
43
+
View, search and tail CloudWatch logs. Laravel and Symfony logs are [structured](/docs/environment/logs): you can filter them by log level or exception class.
37
44
38
45
<ImageclassName="mt-3 rounded-lg shadow-md border"src={cloudLogs}alt="Log viewer in Bref Cloud" />
39
46
40
-
-**Metrics**: monitor Lambda invocations, duration, errors, and more.
41
-
-**Traces**: visualize X-Ray traces to understand the performance of your application, including database queries, HTTP calls, and AWS SDK calls.
47
+
### Metrics
48
+
49
+
The metrics page shows Lambda invocations, duration and errors, as well as API Gateway requests and latency. Queue metrics can also be found in the "Queues" page. You can add graphs to compare metrics over up to 30 days.
50
+
51
+
<ImageclassName="mt-3 rounded-lg shadow-md border"src={cloudMetrics}alt="Metrics in Bref Cloud" />
52
+
53
+
### Traces
54
+
55
+
A trace shows what happens inside an invocation: PHP code, database queries, HTTP calls, and AWS SDK calls. For each AWS call, the trace shows the queue, table, or topic it used.
42
56
43
57
<ImageclassName="mt-3 rounded-lg shadow-md border"src={cloudXrayTrace}alt="X-Ray trace in Bref Cloud" />
44
58
45
-
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:
59
+
The [Bref X-Ray package](/xray) adds annotations to traces: route, controller, job class, CLI command, cold start. You can add [your own annotations](/xray/docs#custom-annotations), for example the tenant or the plan of the user. The trace explorer uses annotations as filters. For example, you can list all the traces of one route, of one job, of one tenant, or all the invocations with a cold start.
60
+
61
+
<ImageclassName="mt-3 rounded-lg shadow-md border"src={cloudTraces}alt="Trace explorer in Bref Cloud" />
62
+
63
+
Enable [AWS Transaction Search](/xray/docs#enabling-aws-transaction-search) on your AWS account, and the trace explorer searches up to 30 days of traces instead of 6 hours. It is a one-time switch in the AWS console.
64
+
65
+
### Performance
66
+
67
+
The Performance page aggregates the traces of the last 30 days. It shows the slowest database queries, the latency of each route, and the slowest jobs.
68
+
69
+
<ImageclassName="mt-3 rounded-lg shadow-md border"src={cloudPerformance}alt="Performance page in Bref Cloud" />
70
+
71
+
-**Slowest database queries**: SQL queries grouped by statement, with the number of calls, the average duration and the p95 duration.
72
+
-**Routes**: server-side processing time per route, sorted by number of requests or by latency. Click a route to open its traces.
73
+
-**Slowest jobs**: queue worker invocations grouped by job class. Click a job to open its traces.
74
+
75
+
The page requires the [Bref X-Ray package](/xray) in the application and [Transaction Search](/xray/docs#enabling-aws-transaction-search) on the AWS account. After that, there is nothing else to configure. Bref Cloud computes the statistics when you open the page, caches them for 24 hours, and lets you recompute them at any time. The statistics only include traced invocations (see the [X-Ray sampling rate](/xray/docs#costs)).
76
+
77
+
### Failed jobs and health checks
78
+
79
+
Laravel applications have a "Failed jobs" tab next to their queues. It shows the exception of each failed job. You can retry, delete or flush jobs from there.
80
+
81
+
Health checks check that a deployed application works: the database is reachable, the cache works, the Lambda functions use the recommended settings. Laravel only for now.
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).
85
+
Bref Cloud paid plans include a free [Bref X-Ray](/xray) license. To activate it, contact support via [bref.cloud/support](https://bref.cloud/support) or [Slack](https://bref.sh/slack).
Copy file name to clipboardExpand all lines: website/content/xray/docs.mdx
+60-13Lines changed: 60 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -104,13 +104,15 @@ Send me a Slack message or an email (matthieu@bref.sh) if you have any trouble,
104
104
105
105
## Enabling AWS Transaction Search
106
106
107
-
[AWS Transaction Search](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Transaction-Search.html) is an AWS service that indexes X-Ray traces and replaces "X-Ray classic" search.
107
+
[AWS Transaction Search](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Transaction-Search.html) is an AWS service that indexes X-Ray traces and replaces "X-Ray classic" search. It is opt-in, and **we recommend enabling it**, whether you explore traces in Bref Cloud or in the AWS console:
108
108
109
-
**Enable it** and Bref Cloud tracing gets much better:
109
+
- search up to 30 days of traces instead of only 6 hours
110
+
- filter traces by route, job, command, cold start, or [any custom annotation](#custom-annotations)
111
+
- spans are stored in CloudWatch Logs (the `aws/spans` log group), so you can also query them with CloudWatch Logs Insights, for example to aggregate durations by route or by SQL query
110
112
111
-
- up to 30 days of traces instead of only 6 hours
112
-
- filter traces by route, job, command, cold start, etc.
113
-
- search all spans rather than only the percentage indexed by "classic X-Ray"
113
+
In Bref Cloud, Transaction Search also unlocks the [Performance page](/docs/monitoring#performance): slowest database queries, latency per route, slowest jobs.
114
+
115
+
If you don't use Bref Cloud, explore traces from the **Transaction Search** page of the CloudWatch console. The classic X-Ray console keeps working but only sees the indexed percentage (see below).
114
116
115
117
Downsides:
116
118
@@ -127,9 +129,9 @@ The change is reversible. To enable Transaction Search ([official guide](https:/
The indexing percentage does _not_ impact Bref Cloud (it is **not** the Lambda sampling rate mentioned in [Costs](#costs) below), leave it at 1% by default. Increase it only if you still use classic X-Ray.
132
+
**Leave the indexing percentage at 1%** unless you know what you are doing. It only affects the classic X-Ray console and APIs. It is not the Lambda sampling rate (see [Costs](#costs)), and it has no effect on Bref Cloud or on the Transaction Search page.
131
133
132
-
It can take up to 10 minutes to activate Transaction Search and see it in Bref Cloud.
134
+
It can take up to 10 minutes to activate Transaction Search and see spans show up, in Bref Cloud or in the CloudWatch console.
133
135
134
136
## Costs
135
137
@@ -150,11 +152,11 @@ This is quite useful: when an application has low traffic, most requests/invocat
150
152
151
153
### Laravel
152
154
153
-
If you are using Laravel, the package automatically integrates with the Laravel service provider. You can see the traces in the AWS X-Ray console.
155
+
If you are using Laravel, the package automatically integrates with the Laravel service provider. You can see the traces in [Bref Cloud](/docs/monitoring#bref-cloud) or in the AWS console.
154
156
155
157
#### Request tracing
156
158
157
-
The package automatically traces all requests to your application. You can see the traces in the AWS X-Ray console.
159
+
The package automatically traces all requests to your application.
158
160
159
161
#### Database queries
160
162
@@ -164,7 +166,7 @@ Eloquent queries are automatically traced and the SQL queries are added to metad
164
166
165
167
#### Jobs
166
168
167
-
The package automatically traces all jobs dispatched via the Laravel queue. You can see the traces in the AWS X-Ray console, and filter them by job name.
169
+
The package automatically traces all jobs dispatched via the Laravel queue. Traces can be filtered by job name.
168
170
169
171

170
172
@@ -178,7 +180,7 @@ The package automatically traces all HTTP requests made via the Laravel HTTP cli
178
180
179
181
### Symfony
180
182
181
-
If you are using Symfony, the package automatically integrates with the Symfony service provider. You can see the traces in the AWS X-Ray console.
183
+
If you are using Symfony, the package automatically integrates with the Symfony service provider. You can see the traces in [Bref Cloud](/docs/monitoring#bref-cloud) or in the AWS console.
182
184
183
185
#### Symfony Messenger
184
186
@@ -282,6 +284,51 @@ XRay::subSegment('doSomething', function () {
282
284
});
283
285
```
284
286
287
+
### Custom annotations
288
+
289
+
Annotations are indexed key-value pairs attached to a trace. Bref adds `Route`, `Controller`, `Job`, `Command`, and cold start annotations automatically. You can add your own, for example the tenant or the plan of the current user:
Call it during the request or the job, for example from a middleware or an event listener. Do not call it at boot time (for example in the `boot()` method of a service provider): the trace is reset after every invocation, so an annotation added at boot is only attached to the first invocation of the Lambda instance.
298
+
299
+
For example, with a Laravel middleware registered in the `web` middleware group:
300
+
301
+
```php
302
+
namespace App\Http\Middleware;
303
+
304
+
use Bref\Apm\XRay\XRay;
305
+
use Closure;
306
+
use Illuminate\Http\Request;
307
+
308
+
class AnnotateTrace
309
+
{
310
+
public function handle(Request $request, Closure $next)
X-Ray has [constraints on annotations](https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-annotations):
323
+
324
+
- keys can only contain letters, numbers and underscores (`feature_flag` is valid, `feature-flag` is not)
325
+
- values are strings
326
+
- a trace can have at most 50 annotations
327
+
328
+
The package does not validate these constraints, and AWS does not report invalid annotations back to your application.
329
+
330
+
In Bref Cloud, every annotation becomes a filter in the trace explorer (with [Transaction Search](#enabling-aws-transaction-search) enabled). For example, you can list all the traces of a given tenant over the last 30 days. Keep the number of possible values limited (an identifier or a category, not free text).
331
+
285
332
### Tracing AWS SDK calls
286
333
287
334
Trace AWS SDK calls with the `AwsSdkTracer::trace($client)` method.
@@ -297,7 +344,7 @@ AwsSdkTracer::trace($client);
297
344
298
345

299
346
300
-
All calls will be traced and appear in the X-Ray console. However, only the first 10 requests will be sampled (i.e. will result in propagating tracing to the target AWS service). This is to avoid oversampling and hitting the X-Ray limit of 100 linked traces. For example, if a Lambda function sends 100 messages to SQS, only the first 10 Lambda invocations triggered by the SQS messages will create sub-traces. The other 90 invocations will appear as segments in the original trace, but will not create sub-traces.
347
+
All calls will be traced and appear in the trace. However, only the first 10 requests will be sampled (i.e. will result in propagating tracing to the target AWS service). This is to avoid oversampling and hitting the X-Ray limit of 100 linked traces. For example, if a Lambda function sends 100 messages to SQS, only the first 10 Lambda invocations triggered by the SQS messages will create sub-traces. The other 90 invocations will appear as segments in the original trace, but will not create sub-traces.
301
348
302
349
### Tracing Async-AWS SDK calls
303
350
@@ -326,7 +373,7 @@ $httpClient = new TracedAsyncAwsHttpClient(HttpClient::create([
326
373
$sqs = new SqsClient([ /* config */ ], null, $httpClient);
327
374
```
328
375
329
-
All calls will be traced and appear in the X-Ray console. However, only the first 10 requests will be sampled (i.e. will result in propagating tracing to the target AWS service). This is to avoid oversampling and hitting the X-Ray limit of 100 linked traces. For example, if a Lambda function sends 100 messages to SQS, only the first 10 Lambda invocations triggered by the SQS messages will create sub-traces. The other 90 invocations will appear as segments in the original trace, but will not create sub-traces.
376
+
All calls will be traced and appear in the trace. However, only the first 10 requests will be sampled (i.e. will result in propagating tracing to the target AWS service). This is to avoid oversampling and hitting the X-Ray limit of 100 linked traces. For example, if a Lambda function sends 100 messages to SQS, only the first 10 Lambda invocations triggered by the SQS messages will create sub-traces. The other 90 invocations will appear as segments in the original trace, but will not create sub-traces.
0 commit comments