Skip to content

A PHP sdk to communicate with the Graylog REST API

License

Notifications You must be signed in to change notification settings

ElevatoDigital/graylog-sdk

This branch is 6 commits ahead of nexylan/graylog-sdk:master.

Repository files navigation

Graylog SDK

Graylog API PHP SDK.

Latest Stable Version Latest Unstable Version License

Total Downloads Monthly Downloads Daily Downloads

Documentation

All the installation and usage instructions are located in this README. Check it for a specific versions:

Prerequisites

This version of the project requires:

  • PHP 7.0+

Installation

First of all, you need to require this library through Composer:

composer require nexylan/graylog-sdk

Usage

$graylog = new \Nexy\Graylog\Graylog([
    'base_uri' => 'https://your.graylog.instance.com/api'
]);

// You may authenticate with API token:
$graylog->auth('YourApiToken');
// Or user credentials:
$graylog->auth('YourGraylogUsername', 'YourGrayLogPassword');

// Then, start using the API:
$result = $graylog->search()->relative()->terms('file', 'source: host.com', 0);

Symfony integration

Activate the bundle:

// config/bundles.php

return [
    Nexy\Graylog\Bridge\Symfony\Bundle\NexyGraylogBundle::class => ['all' => true],
];

Add the configuration file:

// config/packages/nexy_graylog.yaml

nexy_graylog:
    options:
        base_uri:             ~ # Required
    auth:

        # Can be a username or a token.
        user:                 ~ # Required

        # Required only for username auth.
        password:             null

Then, inject the Graylog service thanks to autowiring:

class MyService
{
    private $graylog;

    public function __construct(Nexy\Graylog\Graylog $graylog)
    {
        $this->graylog = $graylog;
    }
}

About

A PHP sdk to communicate with the Graylog REST API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%