All Projects → maxbanton → Cwh

maxbanton / Cwh

Licence: mit
Amazon Web Services CloudWatch Logs Handler for Monolog library

Projects that are alternatives of or similar to Cwh

Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (-82.47%)
Mutual labels:  aws, logs
Cw
The best way to tail AWS CloudWatch Logs from your terminal
Stars: ✭ 368 (+26.46%)
Mutual labels:  aws, logs
Escalator
Escalator is a batch or job optimized horizontal autoscaler for Kubernetes
Stars: ✭ 539 (+85.22%)
Mutual labels:  aws, batch
Saw
Fast, multi-purpose tool for AWS CloudWatch Logs
Stars: ✭ 1,071 (+268.04%)
Mutual labels:  aws, logs
Terraform Aws S3 Log Storage
This module creates an S3 bucket suitable for receiving logs from other AWS services such as S3, CloudFront, and CloudTrail
Stars: ✭ 65 (-77.66%)
Mutual labels:  aws, logs
Stepfunctions2processing
Configuration with AWS step functions and lambdas which initiates processing from activity state
Stars: ✭ 90 (-69.07%)
Mutual labels:  aws, batch
Batchit
simple jobs submission via command-line for AWS batch
Stars: ✭ 77 (-73.54%)
Mutual labels:  aws, batch
Systemdlogger
Exports systemd logs to an external service, eg cloudwatch, elasticsearch
Stars: ✭ 91 (-68.73%)
Mutual labels:  aws, logs
Fluent Plugin S3
Amazon S3 input and output plugin for Fluentd
Stars: ✭ 276 (-5.15%)
Mutual labels:  aws
Serverless Plugin Canary Deployments
Canary deployments for your Serverless application
Stars: ✭ 283 (-2.75%)
Mutual labels:  aws
Aws Auto Cleanup
Open-source application to programmatically clean your AWS resources based on a whitelist and time to live (TTL) settings
Stars: ✭ 276 (-5.15%)
Mutual labels:  aws
Sagify
MLOps for AWS SageMaker. www.sagifyml.com
Stars: ✭ 277 (-4.81%)
Mutual labels:  aws
K8s Spot Rescheduler
Tries to move K8s Pods from on-demand to spot instances
Stars: ✭ 283 (-2.75%)
Mutual labels:  aws
Cloudscraper
CloudScraper: Tool to enumerate targets in search of cloud resources. S3 Buckets, Azure Blobs, Digital Ocean Storage Space.
Stars: ✭ 276 (-5.15%)
Mutual labels:  aws
Jaas
Run jobs (tasks/one-shot containers) with Docker
Stars: ✭ 291 (+0%)
Mutual labels:  batch
Arvados
An open source platform for managing and analyzing biomedical big data
Stars: ✭ 274 (-5.84%)
Mutual labels:  aws
Stern
⎈ Multi pod and container log tailing for Kubernetes -- Friendly fork of https://github.com/wercker/stern
Stars: ✭ 268 (-7.9%)
Mutual labels:  logs
Terraform Aws Notify Slack
Terraform module which creates SNS topic and Lambda function which sends notifications to Slack
Stars: ✭ 290 (-0.34%)
Mutual labels:  aws
Vortex
🌀 Discord Moderation Bot
Stars: ✭ 283 (-2.75%)
Mutual labels:  logs
Ictf Framework
The iCTF Framework, presented by Shellphish!
Stars: ✭ 281 (-3.44%)
Mutual labels:  aws

AWS CloudWatch Logs Handler for Monolog

Actions Status Coverage Status License Version Downloads

Handler for PHP logging library Monolog for sending log entries to AWS CloudWatch Logs service.

Before using this library, it's recommended to get acquainted with the pricing for AWS CloudWatch services.

Please press ★ Star button if you find this library useful.

Disclaimer

This library uses AWS API through AWS PHP SDK, which has limits on concurrent requests. It means that on high concurrent or high load applications it may not work on it's best way. Please consider using another solution such as logging to the stdout and redirecting logs with fluentd.

Requirements

  • PHP ^7.2
  • AWS account with proper permissions (see list of permissions below)

Features

  • Up to 10000 batch logs sending in order to avoid Rate exceeded errors
  • Log Groups creating with tags
  • AWS CloudWatch Logs staff lazy loading
  • Suitable for web applications and for long-living CLI daemons and workers

Installation

Install the latest version with Composer by running

$ composer require maxbanton/cwh:^2.0

Basic Usage

<?php

use Aws\CloudWatchLogs\CloudWatchLogsClient;
use Maxbanton\Cwh\Handler\CloudWatch;
use Monolog\Logger;
use Monolog\Formatter\JsonFormatter;

$sdkParams = [
    'region' => 'eu-west-1',
    'version' => 'latest',
    'credentials' => [
        'key' => 'your AWS key',
        'secret' => 'your AWS secret',
        'token' => 'your AWS session token', // token is optional
    ]
];

// Instantiate AWS SDK CloudWatch Logs Client
$client = new CloudWatchLogsClient($sdkParams);

// Log group name, will be created if none
$groupName = 'php-logtest';

// Log stream name, will be created if none
$streamName = 'ec2-instance-1';

// Days to keep logs, 14 by default. Set to `null` to allow indefinite retention.
$retentionDays = 30;

// Instantiate handler (tags are optional)
$handler = new CloudWatch($client, $groupName, $streamName, $retentionDays, 10000, ['my-awesome-tag' => 'tag-value']);

// Optionally set the JsonFormatter to be able to access your log messages in a structured way
$handler->setFormatter(new JsonFormatter());

// Create a log channel
$log = new Logger('name');

// Set handler
$log->pushHandler($handler);

// Add records to the log
$log->debug('Foo');
$log->warning('Bar');
$log->error('Baz');

Frameworks integration

And many others

AWS IAM needed permissions

if you prefer to use a separate programmatic IAM user (recommended) or want to define a policy, make sure following permissions are included:

  1. CreateLogGroup aws docs
  2. CreateLogStream aws docs
  3. PutLogEvents aws docs
  4. PutRetentionPolicy aws docs
  5. DescribeLogStreams aws docs
  6. DescribeLogGroups aws docs

When setting the $createGroup argument to false, permissions DescribeLogGroups and CreateLogGroup can be omitted

AWS IAM Policy full json example

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogGroup",
                "logs:DescribeLogGroups"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "logs:CreateLogStream",
                "logs:DescribeLogStreams",
                "logs:PutRetentionPolicy"
            ],
            "Resource": "{LOG_GROUP_ARN}"
        },
        {
            "Effect": "Allow",
            "Action": [
                "logs:PutLogEvents"
            ],
            "Resource": [
                "{LOG_STREAM_1_ARN}",
                "{LOG_STREAM_2_ARN}"
            ]
        }
    ]
}

Issues

Feel free to report any issues

Contributing

Please check this document


Made in Ukraine 🇺🇦

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].