fastapi-elasticsearch-middleware


Namefastapi-elasticsearch-middleware JSON
Version 1.1.3 PyPI version JSON
download
home_pagehttps://github.com/GGontijo/fastapi-elasticsearch-middleware.git
SummaryElasticsearch Logger Middleware for FastAPI
upload_time2024-09-18 13:19:01
maintainerNone
docs_urlNone
authorGabriel Gontijo
requires_pythonNone
licenseNone
keywords python middleware fastapi elasticsearch kibana logstash fastapi-middleware
VCS
bugtrack_url
requirements fastapi elasticsearch
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Elasticsearch Logger Middleware for FastAPI

Elasticsearch Logger Middleware for FastAPI is designed to facilitate detailed and efficient logging directly to Elasticsearch servers from FastAPI applications. It streamlines the logging processes by capturing detailed HTTP requests data and automates telemetry to provide insights into application performance.

### Key Features

1. **Elasticsearch Integration:** Send logs directly to an Elasticsearch server.
2. **Flexible Configuration:** Configure to suit various environment needs.
3. **Automated Detailed Data Logging:** Automatically captures headers, query parameters, and the request body.
4. **Effortless Telemetry:** Automatically generates telemetry for monitoring request times.
5. **Enhanced Data Control:** Limit payload sizes for efficient Elasticsearch indexing.

### Installation

To install this middleware, ensure you have Python installed and then run:

```bash
pip install fastapi-elasticsearch-middleware
```

### Usage

Configure the middleware by creating a `config` dictionary in your FastAPI application as follows:

```python
config = {
    'url': 'http://localhost:9200',
    'user': 'elasticsearch_user',
    'password': 'password',
    'index': 'my_app_logs',
    'environment': 'development',
    'limit': True,
    'debug': False
}
```

**The `debug` parameter prevents sending logs to Elasticsearch.**

Integrate the middleware into your FastAPI application like this:

```python
from fastapi import FastAPI
from fastapi_elasticsearch_middleware.elasticsearch_middleware import ElasticsearchLoggerMiddleware

app = FastAPI()
app.add_middleware(ElasticsearchLoggerMiddleware, config=config)
```

### How It Works

The middleware captures each HTTP request, processes it, and sends log data to your Elasticsearch server based on the configured parameters. It includes detailed logs of request headers, body data, and response metrics.


## How to Contribute

We welcome contributions from the community and are pleased to have you join us. Here are some guidelines that will help you get started.

### Prerequisites

Before contributing, please ensure you have the following:
- A basic understanding of Python and FastAPI.
- A basic understanding of Middlewares.

### Setting Up Your Development Environment

1. **Fork the Repository**: Start by forking the repository to your GitHub account.
2. **Clone the Repository**: Clone your fork to your local machine.
   ```bash
   git clone https://github.com/GGontijo/fastapi-elasticsearch-middleware
   cd repository-name
   ```
3. **Install Dependencies**: Install the required dependencies.
   ```bash
   pip install -r requirements.txt
   ```

### Making Changes

1. **Create a New Branch**: Create a new branch for your feature or bug fix.
   ```bash
   git checkout -b awesome-feature
   ```
2. **Make Your Changes**: Implement your feature or fix a bug. Be sure to adhere to the coding standards and include comments where necessary.

### Submitting a Pull Request

1. **Commit Your Changes**: Once your tests pass, commit your changes.
   ```bash
   git commit -m 'Add some feature'
   ```
2. **Push to GitHub**: Push your changes to your fork on GitHub.
   ```bash
   git push origin awesome-feature
   ```
3. **Open a Pull Request**: Go to the original repository and click the *Compare & pull request* button. Then submit your pull request with a clear title and description.

### Code Review

Once your pull request is opened, it will be reviewed by the maintainers. Some changes may be requested. Please be patient and responsive. Once the pull request has been approved, it will be merged into the master branch.

Thank you for contributing!

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/GGontijo/fastapi-elasticsearch-middleware.git",
    "name": "fastapi-elasticsearch-middleware",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "python, middleware, fastapi, elasticsearch, kibana, logstash, fastapi-middleware",
    "author": "Gabriel Gontijo",
    "author_email": "gabrieldercilio08@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0f/b1/e6c14bbd823c321c4adb8afe9a5b458271b9ddacf7df8e5411e8d4b4d220/fastapi_elasticsearch_middleware-1.1.3.tar.gz",
    "platform": null,
    "description": "# Elasticsearch Logger Middleware for FastAPI\n\nElasticsearch Logger Middleware for FastAPI is designed to facilitate detailed and efficient logging directly to Elasticsearch servers from FastAPI applications. It streamlines the logging processes by capturing detailed HTTP requests data and automates telemetry to provide insights into application performance.\n\n### Key Features\n\n1. **Elasticsearch Integration:** Send logs directly to an Elasticsearch server.\n2. **Flexible Configuration:** Configure to suit various environment needs.\n3. **Automated Detailed Data Logging:** Automatically captures headers, query parameters, and the request body.\n4. **Effortless Telemetry:** Automatically generates telemetry for monitoring request times.\n5. **Enhanced Data Control:** Limit payload sizes for efficient Elasticsearch indexing.\n\n### Installation\n\nTo install this middleware, ensure you have Python installed and then run:\n\n```bash\npip install fastapi-elasticsearch-middleware\n```\n\n### Usage\n\nConfigure the middleware by creating a `config` dictionary in your FastAPI application as follows:\n\n```python\nconfig = {\n    'url': 'http://localhost:9200',\n    'user': 'elasticsearch_user',\n    'password': 'password',\n    'index': 'my_app_logs',\n    'environment': 'development',\n    'limit': True,\n    'debug': False\n}\n```\n\n**The `debug` parameter prevents sending logs to Elasticsearch.**\n\nIntegrate the middleware into your FastAPI application like this:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi_elasticsearch_middleware.elasticsearch_middleware import ElasticsearchLoggerMiddleware\n\napp = FastAPI()\napp.add_middleware(ElasticsearchLoggerMiddleware, config=config)\n```\n\n### How It Works\n\nThe middleware captures each HTTP request, processes it, and sends log data to your Elasticsearch server based on the configured parameters. It includes detailed logs of request headers, body data, and response metrics.\n\n\n## How to Contribute\n\nWe welcome contributions from the community and are pleased to have you join us. Here are some guidelines that will help you get started.\n\n### Prerequisites\n\nBefore contributing, please ensure you have the following:\n- A basic understanding of Python and FastAPI.\n- A basic understanding of Middlewares.\n\n### Setting Up Your Development Environment\n\n1. **Fork the Repository**: Start by forking the repository to your GitHub account.\n2. **Clone the Repository**: Clone your fork to your local machine.\n   ```bash\n   git clone https://github.com/GGontijo/fastapi-elasticsearch-middleware\n   cd repository-name\n   ```\n3. **Install Dependencies**: Install the required dependencies.\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n### Making Changes\n\n1. **Create a New Branch**: Create a new branch for your feature or bug fix.\n   ```bash\n   git checkout -b awesome-feature\n   ```\n2. **Make Your Changes**: Implement your feature or fix a bug. Be sure to adhere to the coding standards and include comments where necessary.\n\n### Submitting a Pull Request\n\n1. **Commit Your Changes**: Once your tests pass, commit your changes.\n   ```bash\n   git commit -m 'Add some feature'\n   ```\n2. **Push to GitHub**: Push your changes to your fork on GitHub.\n   ```bash\n   git push origin awesome-feature\n   ```\n3. **Open a Pull Request**: Go to the original repository and click the *Compare & pull request* button. Then submit your pull request with a clear title and description.\n\n### Code Review\n\nOnce your pull request is opened, it will be reviewed by the maintainers. Some changes may be requested. Please be patient and responsive. Once the pull request has been approved, it will be merged into the master branch.\n\nThank you for contributing!\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Elasticsearch Logger Middleware for FastAPI",
    "version": "1.1.3",
    "project_urls": {
        "Homepage": "https://github.com/GGontijo/fastapi-elasticsearch-middleware.git"
    },
    "split_keywords": [
        "python",
        " middleware",
        " fastapi",
        " elasticsearch",
        " kibana",
        " logstash",
        " fastapi-middleware"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ca3da5944f1a92187e54b211e0cd7f0a8bcbfd6e66b3a387f9aae9c4cbab27f7",
                "md5": "9170c86c80e4b1a473779a17d8f101a1",
                "sha256": "c00447781cdec8dab2d59a826b34b07325ecbde1e661c8fe4b9e599a648b31d8"
            },
            "downloads": -1,
            "filename": "fastapi_elasticsearch_middleware-1.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9170c86c80e4b1a473779a17d8f101a1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6331,
            "upload_time": "2024-09-18T13:19:00",
            "upload_time_iso_8601": "2024-09-18T13:19:00.894539Z",
            "url": "https://files.pythonhosted.org/packages/ca/3d/a5944f1a92187e54b211e0cd7f0a8bcbfd6e66b3a387f9aae9c4cbab27f7/fastapi_elasticsearch_middleware-1.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0fb1e6c14bbd823c321c4adb8afe9a5b458271b9ddacf7df8e5411e8d4b4d220",
                "md5": "d51d89f1f8e228d1b9c38130c8c57542",
                "sha256": "f0c5d1e9421abb08811d8bcc4692db087f81a20876fd6d3166c628c7de5f0f70"
            },
            "downloads": -1,
            "filename": "fastapi_elasticsearch_middleware-1.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "d51d89f1f8e228d1b9c38130c8c57542",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5663,
            "upload_time": "2024-09-18T13:19:01",
            "upload_time_iso_8601": "2024-09-18T13:19:01.761386Z",
            "url": "https://files.pythonhosted.org/packages/0f/b1/e6c14bbd823c321c4adb8afe9a5b458271b9ddacf7df8e5411e8d4b4d220/fastapi_elasticsearch_middleware-1.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-18 13:19:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "GGontijo",
    "github_project": "fastapi-elasticsearch-middleware",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "fastapi",
            "specs": []
        },
        {
            "name": "elasticsearch",
            "specs": []
        }
    ],
    "lcname": "fastapi-elasticsearch-middleware"
}
        
Elapsed time: 4.15972s