{ "info": { "author": "Rafael Francisco Viana Sanches", "author_email": "rafaelsanches123@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.6" ], "description": "# Project description\n\n## Graylog Http Gelf with Python\n### Description\n\nThis library aims to simplify the process of sending logs to your graylog server using the python language.\n\nTo use this lib is necessary before have create input using GELF HTTP in input area on your Graylog GUI (web page) in port 9000 on your browser.\n\n## First step\n\nThe first step is to install the __gray-py-gelf__ library by managing python packages using pip:\n\n```\npip install gray-py-gelf\n```\n\n## Second step\n\nSome extra libs used in this example to compose own log.\n\n```\nfrom datetime import date\nfrom time import gmtime, strftime\ntoday = date.today()\n```\n\nImport gray-py-gelf in your python code using:\n```\nfrom graylog_lib.graylog_http_gelf import Graylog\n```\n\n## Third step\n\n### Instantiating the graylog object from its constructor pass by parameter:\n\n```\ngraylog = Graylog(url=\"http://localhost:12201/gelf\", host=\"Rafael's Notebook\", short_message=\"my_indice_name\", level=6)\n\n```\n### Creating your log to send to graylog GELF\n#### Remember that your GELF input must already be created before sending any logs to Graylog to manage:\n```\nlog = '\"id\":{},\"name\":\"{}\",\"age\":{},\"date\":\"{}\",\"hour\":\"{}\"'.format(1, \"Rafael Sanches\", 28, today.strftime(\"%d/%m/%Y\"), strftime(\"%H:%M:%S\", gmtime()))\nlog = '{'+log+'}'\n\nresp = graylog.sender(log)\n\nprint(resp)\n```\n\n# You must import this extractor before you can start uploading your logs to Graylog.\n\nExtractors to safe your life and transform your log in separated keys and values:\n\nImport this extractor in your input GELF HTTP:\n```\n{\n \"extractors\": [\n {\n \"title\": \"extractor_json\",\n \"extractor_type\": \"json\",\n \"converters\": [],\n \"order\": 0,\n \"cursor_strategy\": \"copy\",\n \"source_field\": \"json\",\n \"target_field\": \"\",\n \"extractor_config\": {\n \"list_separator\": \", \",\n \"kv_separator\": \"=\",\n \"key_prefix\": \"\",\n \"key_separator\": \"_\",\n \"replace_key_whitespace\": true,\n \"key_whitespace_replacement\": \"_\"\n },\n \"condition_type\": \"none\",\n \"condition_value\": \"\"\n }\n ],\n \"version\": \"3.0.2\"\n}\n```\nSome tips:\n * No mark 'flatten' option field when you will go to create your extractor;\n * Mark 'key_whitespace_replacement' and set some thing type _\n\nMeans about atributes graylog object:\n * url: Your graylog server and port used to GELF\n * host: Who send this log? e.g ip the machine for example\n * level: A integer number that represents a level about your log content\n * short_message: Use this field to represent your index\n * sender: Is a method to send a string type a json to lib python and there is a pre-processing and send all infos to your graylog server in a json format. This method give return to you a http 202 code if all that's OK.\n\n# Example full code:\n```\nfrom datetime import date\nfrom time import gmtime, strftime\ntoday = date.today()\n\nfrom graylog_lib.graylog_http_gelf import Graylog\n\ngraylog = Graylog(url=\"http://localhost:12201/gelf\", host=\"Rafael's Notebook\", short_message=\"rafael_test\", level=6)\nfor i in range(50):\n log = '\"id\":{},\"name\":\"{}\",\"age\":{},\"date\":\"{}\",\"hour\":\"{}\"'.format(i, \"Rafael Sanches\", 28, today.strftime(\"%d/%m/%Y\"), strftime(\"%H:%M:%S\", gmtime()))\n log = '{'+log+'}'\n print(type(log))\n print(log)\n resp = graylog.sender(log)\n print(resp)\n```\n\nAny questions feel free to send me an email: __rafaelsanches123@gmail.com__\nIf you want to see cool things in python visit my personal [blog](https://rafaelsanches123.github.io/)!\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/rafaelsanches123/GraylogHttpGelfPython", "keywords": "graylog,python3.6,json,api,rafael sanches", "license": "", "maintainer": "", "maintainer_email": "", "name": "gray-py-gelf", "package_url": "https://pypi.org/project/gray-py-gelf/", "platform": "", "project_url": "https://pypi.org/project/gray-py-gelf/", "project_urls": { "Homepage": "https://github.com/rafaelsanches123/GraylogHttpGelfPython" }, "release_url": "https://pypi.org/project/gray-py-gelf/1.2.0/", "requires_dist": [ "requests" ], "requires_python": ">=3.6", "summary": "This project aims to simplify log shipping to your graylog server quite simply", "version": "1.2.0" }, "last_serial": 6005052, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "a0550a688649ded9531005fa801752a0", "sha256": "7463e6994c7dfee0bf5914a5e5b9c2456bd2762a2f4cebb15e773b557244d2ad" }, "downloads": -1, "filename": "gray_py_gelf-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "a0550a688649ded9531005fa801752a0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 6236, "upload_time": "2019-10-04T17:55:49", "url": "https://files.pythonhosted.org/packages/fb/3a/5cfbd468d32423c818ca0b0abcf70ce0343f634ad5bf548c54d5aa94b620/gray_py_gelf-1.0.0-py3-none-any.whl" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "264a1378568c16a59575c286360f7bc1", "sha256": "6a7049e8804132b813adb607e160f7751e92b9c255274bfdc0787332eeb5a77e" }, "downloads": -1, "filename": "gray_py_gelf-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "264a1378568c16a59575c286360f7bc1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 7355, "upload_time": "2019-10-11T16:41:22", "url": "https://files.pythonhosted.org/packages/45/48/e211dc18248da598b57378ae918c97c8fd5d9cc57c0313b7d681bac34960/gray_py_gelf-1.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e68bc7f2e260c2ed1297c7c1c20e800b", "sha256": "6ccc2ab7e1c2ee0e2ee126db75e36fcbda8e4af7ab80c83d0492da69f81cf837" }, "downloads": -1, "filename": "gray_py_gelf-1.1.0.tar.gz", "has_sig": false, "md5_digest": "e68bc7f2e260c2ed1297c7c1c20e800b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 3059, "upload_time": "2019-10-11T16:41:24", "url": "https://files.pythonhosted.org/packages/e7/f3/9026c2ac58c643a3c8b6c42b83cd02d054b61a21079503d66de1c12f078c/gray_py_gelf-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "ba65fa51e27cdf1b47feb9a623cd8ced", "sha256": "d68b0eef9fbbd6da7351eb7de55346bc31d6704f4fa124bc19e814d99ea5167a" }, "downloads": -1, "filename": "gray_py_gelf-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ba65fa51e27cdf1b47feb9a623cd8ced", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 7592, "upload_time": "2019-10-21T00:30:22", "url": "https://files.pythonhosted.org/packages/bb/65/163472c7beded0488f5741e34587d765ecd19cf552cb9afced9771fa2d99/gray_py_gelf-1.2.0-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ba65fa51e27cdf1b47feb9a623cd8ced", "sha256": "d68b0eef9fbbd6da7351eb7de55346bc31d6704f4fa124bc19e814d99ea5167a" }, "downloads": -1, "filename": "gray_py_gelf-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ba65fa51e27cdf1b47feb9a623cd8ced", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 7592, "upload_time": "2019-10-21T00:30:22", "url": "https://files.pythonhosted.org/packages/bb/65/163472c7beded0488f5741e34587d765ecd19cf552cb9afced9771fa2d99/gray_py_gelf-1.2.0-py3-none-any.whl" } ] }