{"id":27899193,"url":"https://github.com/rolandort/log2graylog","last_synced_at":"2026-05-15T18:31:31.765Z","repository":{"id":291454131,"uuid":"977286383","full_name":"rolandort/log2graylog","owner":"rolandort","description":"A command-line tool that parses log messages from files and forwards them to a Graylog server using the GELF HTTP input protocol.","archived":false,"fork":false,"pushed_at":"2025-05-04T18:52:15.000Z","size":724,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T19:22:52.234Z","etag":null,"topics":["gelf","graylog","json","logfile"],"latest_commit_sha":null,"homepage":"https://github.com/Graylog2/graylog-project","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rolandort.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-03T21:05:15.000Z","updated_at":"2025-05-04T18:52:19.000Z","dependencies_parsed_at":"2025-05-04T19:32:04.931Z","dependency_job_id":null,"html_url":"https://github.com/rolandort/log2graylog","commit_stats":null,"previous_names":["rolandort/log2graylog"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolandort%2Flog2graylog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolandort%2Flog2graylog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolandort%2Flog2graylog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rolandort%2Flog2graylog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rolandort","download_url":"https://codeload.github.com/rolandort/log2graylog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252561127,"owners_count":21768070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gelf","graylog","json","logfile"],"created_at":"2025-05-05T19:22:51.575Z","updated_at":"2025-10-19T13:47:44.060Z","avatar_url":"https://github.com/rolandort.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Log2Graylog\n\n[![Java Version](https://img.shields.io/badge/Java-17-blue.svg)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA command-line tool that parses log messages from files and forwards them to a Graylog server using the GELF HTTP input protocol.\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Features](#features)\n- [Installation](#installation)\n  - [Prerequisites](#prerequisites)\n  - [Building from Source](#building-from-source)\n- [Usage](#usage)\n  - [Command Line Options](#command-line-options)\n  - [Examples](#examples)\n- [Architecture](#architecture)\n- [Development](#development)\n  - [Project Structure](#project-structure)\n  - [Testing](#testing)\n- [Possible Improvements](#possible-improvements)\n- [Author](#author)\n- [License](#license)\n\n## Overview\n\nLog2Graylog is a command-line utility for parsing log files in JSON or CSV format (other formats may be supported in future) and sending the content to a Graylog server.\nThe app converts the log messages into the Graylog Extended Log Format (GELF) format and pushes them to the GELF HTTP input endpoint of the Graylog server.\n\n![Graylog Screenshot showing log messages processed by Log2Graylog](docs/images/graylog-screenshot.png)  \n*Screenshot of Graylog after importing log messages using Log2Graylog*\n\n## Features\n\n- Parse log messages from files with specific formats (JSON, CSV)\n- Extract and map fields from log messages to GELF format\n- Add additional metadata to log entries\n- Send GELF messages to a Graylog server over HTTP\n- Options for specifying the Graylog server URL and timeout\n\n## Installation\n\n### Prerequisites\n\n- Java 17 or higher\n- Maven 3.6 or higher\n- A running Graylog server with a GELF HTTP input configured (see https://github.com/Graylog2/graylog-project)\n\n### Building from Source\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/rolandort/log2graylog.git\n   cd log2graylog\n   ```\n\n2. Build the application using Maven:\n   ```bash\n   mvn clean package\n   ```\n\nThis will create an executable JAR file in the `target` directory.\n\n## Usage\n\n### Command Line Options\n\n```\nUsage: Log2Graylog [-hvV] [-p=\u003cparserType\u003e] [-s=\u003csenderType\u003e] [-t=\u003ctimeout\u003e]\n                   [-u=\u003cgraylogUrl\u003e] LOG_FILE\nParses log messages and send them to Graylog using the GELF format.\n      LOG_FILE              Logfile to parse as input\n  -h, --help                Show this help message and exit.\n  -p, --parser=\u003cparserType\u003e Parser type (JSON|CSV, default: JSON)\n  -s, --sender=\u003csenderType\u003e Sender type (SIMULATE|HTTP, default: HTTP)\n  -t, --timeout=\u003ctimeout\u003e   Timeout of HTTP requests in seconds. (default: 10\n                              sec)\n  -u, --url=\u003cgraylogUrl\u003e    Output URL of the Graylog GELF HTTP interface\n                              (default: http://localhost:12202/gelf)\n  -v, --verbose             Enable verbose output\n  -V, --version             Print version information and exit.\n```\n\n### Examples\n\nBasic usage with JSON log file, HTTP sender and default Graylog URL (http://localhost:12202/gelf):\n```bash\njava -jar target/log2graylog-1.1-SNAPSHOT.jar sample-messages.txt\n```\n\nCustom Graylog URL and timeout\n```bash\njava -jar target/log2graylog-1.1-SNAPSHOT.jar -v --timeout 30 --url http://graylog-server:12202/gelf sample-messages.txt\n```\n\nCSV log file and simulated sender\n```bash\njava -jar target/log2graylog-1.1-SNAPSHOT.jar --parser CSV --sender SIMULATE sample-messages.csv\n```\n\nExample source JSON log message:\n\n```json\n{\n  \"ClientDeviceType\": \"desktop\",\n  \"ClientIP\": \"192.168.211.15\",\n  \"ClientIPClass\": \"noRecord\",\n  \"ClientStatus\": 550, \n  \"ClientRequestBytes\": 63,\n  \"ClientRequestReferer\": \"torch.sh\",\n  \"ClientRequestURI\": \"/search\",\n  \"ClientRequestUserAgent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64)\",\n  \"ClientSrcPort\":450,\n  \"EdgeServerIP\": \"10.0.88.33\",\n  \"EdgeStartTimestamp\": 1576929197,\n  \"DestinationIP\": \"172.16.45.194\",\n  \"OriginResponseBytes\": 957,\n  \"OriginResponseTime\": 398000000\n}\n```\nExample source CSV log message:\n\n```csv\nClientDeviceType,ClientIP,ClientIPClass,ClientStatus,ClientRequestBytes,ClientRequestReferer,ClientRequestURI,ClientRequestUserAgent,ClientSrcPort,EdgeServerIP,EdgeStartTimestamp,DestinationIP,OriginResponseBytes,OriginResponseTime\ndesktop,192.168.237.181,noRecord,200,927,torch.sh,/search,\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15\",564,10.0.56.97,1576929197,172.16.101.17,571,296000000\n```\n\n## Architecture\n\nLog2Graylog uses a modular architecture with the following components:\n\n1. **CLI** - Command-line interface library for Java\n2. **Log Parser** - Reads and parses log files into structured data\n3. **GELF Formatter** - Converts parsed log entries to GELF format\n4. **HTTP Sender** - Sends GELF messages to the Graylog server\n\n### Dependencies\n\n- PicoCli - Command-line interface library for Java\n- Google Guice - Dependency injection framework\n- Gson - JSON parsing library\n- Opencsv - CSV parsing library\n- Log4j - Logging framework\n- Lombok - Code generation library\n- Junit - Unit testing framework\n\n## Development\n\n### Project Structure\n\n```\nsrc/main/java/org/rolandort/\n├── Main.java                  # Application entry point\n├── cli/                       # Command-line interface\n├── di/                        # Dependency injection\n├── formatter/                 # GELF message formatting\n├── model/                     # Data models\n├── parser/                    # Log file parsing\n├── sender/                    # HTTP communication\n└── service/                   # Business logic\n```\n\n### Testing\n\nTo run the tests:\n```bash\nmvn test\n```\n\n## Possible Improvements\n\n- **Feature Additions**:\n  - [x] Support for additional log formats with option to select the format\n  - [ ] Configurable log format mapping in a JSON file\n  - [ ] Accept multiple logfiles as input\n  - [x] Dry-run option - DONE (using --sender SIMULATE)\n\n- **Performance Enhancements**:\n  - [ ] Support for large log files (10+ GB) through chunking and parallel processing\n  - [ ] Performance optimizations using asynchronous HTTP requests (using CompletableFuture or PushPromiseHandler)\n  - [ ] Batch processing to reduce the number of HTTP requests\n\n- **Technical Debt**:\n  - [x] Improve naming conventions for formatters based on log sources\n  - [ ] Enhance error handling and reporting\n  - [ ] Additional unit tests\n  - [ ] provide stats on import e.g. throughput, error rate, max/min timestamp, ... \n  - [ ] Log file rotation config in log4j2.xml\n  - [ ] Direct integration with Log4J2 GELF appender\n  - [ ] Optionals (isPresent) for additional fields missing fields\n  - [ ] Jackson vs. Gson (remove unneeded dependencies)\n  - [x] Accepts response code 30x (redirects)\n  - [ ] Replace Lombok\n\n## Author\n\nThis project was created by [Roland Ortner](https://www.linkedin.com/in/roland-ortner/).\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frolandort%2Flog2graylog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frolandort%2Flog2graylog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frolandort%2Flog2graylog/lists"}