fastapi-elasticsearch-middleware


Namefastapi-elasticsearch-middleware JSON
Version 1.0.6 PyPI version JSON
download
home_pagehttps://github.com/GGontijo/fastapi-elasticsearch-middleware.git
SummaryElasticsearch Logger Middleware for FastAPI
upload_time2024-05-13 18:22:31
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 my_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/your-username/repository-name.git
   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/17/37/721dad77e887316f799346d66456f87fc65a0aadeced0428d4ab9205f664/fastapi_elasticsearch_middleware-1.0.6.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 my_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/your-username/repository-name.git\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.0.6",
    "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": "dca4620b343feeeae0c5c8c20606b8650858c6a7bb010470fee81436199eedd1",
                "md5": "d170a29742933c202f2b45deada4669f",
                "sha256": "1d3db1de4439810578ef7eba6c65e731d531c7a32473aeaed98ab491c2f79f83"
            },
            "downloads": -1,
            "filename": "fastapi_elasticsearch_middleware-1.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d170a29742933c202f2b45deada4669f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6350,
            "upload_time": "2024-05-13T18:22:30",
            "upload_time_iso_8601": "2024-05-13T18:22:30.702520Z",
            "url": "https://files.pythonhosted.org/packages/dc/a4/620b343feeeae0c5c8c20606b8650858c6a7bb010470fee81436199eedd1/fastapi_elasticsearch_middleware-1.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1737721dad77e887316f799346d66456f87fc65a0aadeced0428d4ab9205f664",
                "md5": "24bb0b59ea6b73c09d2d80b2d2260058",
                "sha256": "a99249cc3a2131f7bb7fc077c23ca6cea41cfb7fe42d3a45d0d5613e34bfb348"
            },
            "downloads": -1,
            "filename": "fastapi_elasticsearch_middleware-1.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "24bb0b59ea6b73c09d2d80b2d2260058",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5671,
            "upload_time": "2024-05-13T18:22:31",
            "upload_time_iso_8601": "2024-05-13T18:22:31.836319Z",
            "url": "https://files.pythonhosted.org/packages/17/37/721dad77e887316f799346d66456f87fc65a0aadeced0428d4ab9205f664/fastapi_elasticsearch_middleware-1.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-13 18:22:31",
    "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: 0.27470s