Download the PHP package matteomeloni/cloudwatch-logs without Composer
On this page you can find all versions of the php package matteomeloni/cloudwatch-logs. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download matteomeloni/cloudwatch-logs
More information about matteomeloni/cloudwatch-logs
Files in matteomeloni/cloudwatch-logs
Package cloudwatch-logs
Short Description Eloquent syntax for store and retrieve logs from Aws CloudWatch Logs.
License MIT
Homepage https://github.com/matteomeloni/aws-cloudwatch-logs
Informations about the package cloudwatch-logs
AwsCloudwatchLogs
Eloquent syntax for store and retrieve logs from Aws CloudWatch Logs.
-
Installation
-
Usage
-
Mutators and Casting
-
Defining An Accessor
-
Defining A Mutator
-
Attribute Casting
-
Retrieving Models
-
Building Queries
-
Select
-
Conditions
-
Logical Grouping
-
Ordering
-
Limit
-
Aggregates
- Retrieving Single Model
-
-
Retrieving Single Model
-
Store New Log
- Requirements
-
Installation
Via Composer
Run
Update AWS CloudWatch Logs config in config/aws-cloudwatch-logs.php
Usage
Extends your model with Matteomeloni\CloudwatchLogs\CloudWatchLogs
Mutators and Casting
Defining An Accessor
An accessor transforms an attribute value when it is accessed. To define an accessor, create a get {Attribute} Attribute method on your model where {Attribute} is the "studly" cased name of the column you wish to access.
Defining A Mutator
A mutator transforms an attribute value when it is set. To define a mutator, define a set{Attribute}Attribute
method on your model where {Attribute}
is the "studly" cased name of the column you wish to access.
Attribute Casting
Your model's $casts property provides a convenient method of converting attributes to common data types.
The $casts property should be an array where the key is the name of the attribute being cast and the value is the type you wish to cast the column to.
See the Laravel documentation to learn more.
Retrieving Models
The model's all
method will retrieve all of the logs from the model's associated logGroupName and logStreamName.
By default, all logs generated on the current day will be extracted.
If you want to change the time interval, then just use the whereBetween
method
Building Queries
This package support the "CloudWatch Logs Insights" feature.
For more information of this feature, you can see the Aws CloudWatch Logs Insight Documentation
To start a new query you can use the query
method and the result of this operation is the queryId
string, to be used to retrieve the query results:
Select
The select
method allows you to specify which columns to show in the query result.
Conditions
Avaialable comparison operators: =
!=
<
<=
>
>=
Logical Grouping
Sometimes it may be necessary to group several "where" clauses in parentheses to achieve logical grouping in the query.
To accomplish this, you may pass a closure to the where
method:
Ordering
The orderBy
method allows sorting of the query by a given column.
The first argument accepted by this metod, should be the column you wish to sort by and the second argument, determines the direction of the sort, asc
or desc
Limit
The take
or limit
method allows to limit the number of results returned from the query.
Aggregates
This library also provides a variety of methods for retrieving aggregate values like count
, min
, max
, sum
, and avg
.
For more information of this feature, you can see the Aws CloudWatch Logs Insigiht Documentation
You may call any of these methods after constructing your query:
It is possible to group and aggregate the results through the groupBy
method.
In this case the result of the operation will be a collection.
In addition to a specific column, it is also possible to group for all the functions offered by the AWS CloudWatch Logs Insights service.
Retrieving Single Model
In addition to retrieving all of the records matching a given query, you may also retrieve single records using the find
or first
methods.
Store new log
To insert a new record into AWS CloudWatch Log, you should instantiate a new model instance and set attributes on the model.
Then, call the save method on the model instance:
Alternatively, you may use the create method to "save" a new log using a single PHP statement. The inserted log instance will be returned to you by the create method:
Requirements
-
php 7.4 or later
Laravel 7 or later
Change log
Please see the changelog for more information on what has changed recently.
Testing
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Matteo Meloni
- All Contributors
License
The MIT License (MIT). Please see License File for more information.