Inital Adding of Compose Files

This commit is contained in:
mindesbunister
2025-06-24 13:31:31 +02:00
parent 2a146b67fb
commit 1f2b05c937
87 changed files with 30542 additions and 0 deletions

View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,200 @@
## grafana-loki-syslog-aio
<center><img src="https://github.com/lux4rd0/grafana-loki-syslog-aio/blob/main/loki_syslog_aio.png"></center>
## About The Project
This Loki Syslog All-In-One example is geared to help you get up and running quickly with a Syslog ingestor and visualization of logs. It uses [Grafana Loki](https://grafana.com/oss/loki/) and Promtail as a receiver for forwarded syslog-ng logs. I wrote an [introductory blog post](https://labs.lux4rd0.com/2021/01/oldskool-syslog-meets-newskool-loki/) about how this AIO project came about as well (pesky intermittent network issues!!)
<center><img src="https://github.com/lux4rd0/grafana-loki-syslog-aio/blob/main/loki_syslog_aio_overview_sized.png"></center>
*Note that this All In One is geared towards getting network traffic from legacy syslog (RFC3164 UDP port 514) into Loki via [syslog-ng](https://www.syslog-ng.com/) and [Promtail](https://grafana.com/docs/loki/latest/clients/promtail/).*
Essentially:
> RFC3164 Network/Compute Devices -> syslog-ng (UDP port 514) ->
> Promtail (port 1514) -> Loki (port 3100) <- Grafana (port 3000)
## Getting Started
The project is built around a pre-configured Docker stack of the following:
- [Grafana](https://grafana.com/oss/grafana/)
- [Grafana Loki](https://grafana.com/oss/loki/) (configured for [MinIO](https://min.io/))
- [Grafana Promtail](https://grafana.com/docs/loki/latest/clients/promtail/)
- [syslog-ng](https://www.syslog-ng.com/)
The stack has been extended to include pre-configured monitoring with:
- [Prometheus](https://grafana.com/oss/prometheus/)
- [Node-Exporter](https://github.com/prometheus/node_exporter)
- [cAdvisor](https://github.com/google/cadvisor)
A simple Syslog generator is included based on Vicente Zepeda Mas's [random-logger](https://github.com/chentex/random-logger) project.
## Prerequisites
- [Docker](https://docs.docker.com/install)
- [Docker Compose](https://docs.docker.com/compose/install)
## Using
This project is built and tested on Linux CentOS 7. To get started, download the code from this repository and extract it into an empty directory. For example:
wget https://github.com/lux4rd0/grafana-loki-syslog-aio/archive/main.zip
unzip main.zip
cd grafana-loki-syslog-aio-main
From that directory, run the docker-compose command:
**Full Example Stack:** Grafana, Loki with s3/MinIO, Promtail, syslog-ng, Prometheus, cAdvisor, node-exporter
docker-compose -f ./docker-compose.yml up -d
This will start to download all of the needed application containers and start them up.
*(Optional docker-compose configurations are listed under **Options** below)*
**Grafana Dashboards**
Once all of the docker containers are started up, point your Web browser to the Grafana page, typically http://hostname:3000/ - with hostname being the name of the server you ran the docker-compose up -d command on. The "Loki Syslog AIO - Overview" dashboard is defaulted without having to log in.
*Note: this docker-compose stack is designed to be as easy as possible to deploy and go. Logins have been disabled, and the default user has an admin role. This can be changed to an Editor or Viewer role by changing the Grafana environmental variable in the docker-compose.yml file to:*
GF_AUTH_ANONYMOUS_ORG_ROLE: Viewer
**Getting Started With Loki**
Here are some additional resources you might find helpful if you're just getting started with Loki:
- [Getting started with Grafana and Loki in under 4
minutes](https://grafana.com/go/webinar/loki-getting-started/)
- [An (only slightly technical) introduction to Loki](https://grafana.com/blog/2020/05/12/an-only-slightly-technical-introduction-to-loki-the-prometheus-inspired-open-source-logging-system/)
- [Video tutorial: Effective troubleshooting queries with Grafana
Loki](https://grafana.com/blog/2021/01/07/video-tutorial-effective-troubleshooting-queries-with-grafana-loki/)
## Stack Options:
A few other docker-compose files are also available:
**Full Example Stack with Syslog Generator:** Grafana, Loki with s3/MinIO, Promtail, syslog-ng, Prometheus, cAdvisor, node-exporter, Syslog Generator
docker-compose -f ./docker-compose-with-generator.yml up -d
**Example Stack without monitoring or Syslog generator**: Grafana, Loki with s3/MinIO, Promtail, syslog-ng
docker-compose -f ./docker-compose-without-monitoring.yml up -d
**Example Stack without MinIO, monitoring, or Syslog generator:** Grafana, Loki with the filesystem, Promtail, syslog-ng
docker-compose -f ./docker-compose-filesystem.yml up -d
The *Syslog Generator* configuration will need access to the Internet to do a local docker build from the configurations location in ./generator. It'll provide some named hosts and random INFO, WARN, DEBUG, ERROR logs sent over to syslog-ng/Loki.
<center><img src="https://github.com/lux4rd0/grafana-loki-syslog-aio/blob/main/loki_syslog_aio_overview_generator_sized.png"></center>
## Configuration Review:
The default Loki storage configuration docker-compose.yml uses S3 storage with MinIO. If you want to use the filesystem instead, use the different docker-compose configurations listed above or change the configuration directly. An example would be:
volumes:
- ./config/loki-config-filesystem.ym:/etc/loki/loki-config.yml:ro
**Changing MinIO Keys**
The MinIO configurations default the Access Key and Secret Key at startup. If you want to change them, you'll need to update two files:
./docker-compose.yml
MINIO_ACCESS_KEY: minio123
MINIO_SECRET_KEY: minio456
./config/loki-config-s3.yml
aws:
s3: s3://minio123:minio456@minio.:9000/loki
## Changed Default Configurations In syslog-ng and Promtail
To set this example All In One project up, the following configurations have been added to the docker-compose.yml. If you already have syslog-ng running on your deployment server - make similar changes below and comment out the docker container stanza.
#### SYSLOG-NG CONFIGURATION (docker container listens on port 514)
**# syslog-ng.conf**
source s_local {
internal();
};
source s_network {
default-network-drivers(
);
};
destination d_loki {
syslog("promtail" transport("tcp") port("1514"));
};
log {
source(s_local);
source(s_network);
destination(d_loki);
};
> Note: the above "`promtail`" configuration for `destination d_loki` is
> the *hostname* where Promtail is running. Is this example, it happens
> to be the Promtail *docker container* name that I configured for the
> All-In-One example.
#### PROMTAIL CONFIGURATION (docker container listens on port 1514)
**# promtail-config.yml**
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
- url: http://loki:3100/loki/api/v1/push
scrape_configs:
- job_name: syslog
syslog:
listen_address: 0.0.0.0:1514
idle_timeout: 60s
label_structured_data: yes
labels:
job: "syslog"
relabel_configs:
- source_labels: ['__syslog_message_hostname']
target_label: 'host'
## Contributing
Contributions make the open source community such a fantastic place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (git checkout -b feature/AmazingFeature)
- Commit your Changes (git commit -m 'Add some AmazingFeature')
- Push to the Branch (git push origin feature/AmazingFeature)
- Open a Pull Request
## Contact
Dave Schmid - [@lux4rd0](https://twitter.com/lux4rd0) - dave@pulpfree.org
Project Link: https://github.com/lux4rd0/grafana-loki-syslog-aio
## Acknowledgements
- Grafana Labs - https://grafana.com/
- Grafana Loki - https://grafana.com/oss/loki/
- Grafana - https://grafana.com/oss/grafana/
- syslog-ng - https://www.syslog-ng.com/
- Random Logger - https://github.com/chentex/random-logger
- Grafana Dashboard Community (Performance Overviews) - https://grafana.com/grafana/dashboards

View File

@@ -0,0 +1,436 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
},
{
"datasource": "Loki",
"enable": false,
"expr": "{job=\"syslog\"} |=\"DNS request timed out\"",
"hide": false,
"iconColor": "#C4162A",
"limit": 100,
"name": "DNS Timeout",
"showIn": 0,
"tags": [],
"target": {},
"type": "tags"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": 9,
"iteration": 1629593809615,
"links": [
{
"asDropdown": true,
"icon": "external link",
"keepTime": true,
"tags": [
"performance_overview"
],
"title": "Performance Overview",
"type": "dashboards"
}
],
"panels": [
{
"datasource": "Loki",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 30,
"gradientMode": "opacity",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "smooth",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
"mode": "normal"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 24,
"x": 0,
"y": 0
},
"id": 3,
"interval": "$smooth",
"options": {
"legend": {
"calcs": [
"mean",
"sum"
],
"displayMode": "table",
"placement": "right"
},
"tooltip": {
"mode": "single"
}
},
"pluginVersion": "8.1.2",
"targets": [
{
"expr": "count_over_time({job=\"syslog\"}[$__interval])",
"legendFormat": "{{host}}",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Log Line Counts By Host (Unfiltered)",
"transformations": [],
"type": "timeseries"
},
{
"datasource": "Loki",
"description": "",
"fieldConfig": {
"defaults": {
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "semi-dark-orange",
"value": null
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 12,
"w": 24,
"x": 0,
"y": 9
},
"id": 4,
"interval": "$smooth",
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"sum"
],
"fields": "",
"values": false
},
"text": {},
"textMode": "auto"
},
"pluginVersion": "8.1.2",
"targets": [
{
"expr": "count_over_time({host=~\"$host\", job=\"syslog\"} [$__interval] |~ \"$free_form_filter\" |~ \"$filter\")",
"legendFormat": "{{host}}",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Counts By Host ($host) - \"$filter\" - \"$free_form_filter\" (Filtered)",
"transformations": [],
"type": "stat"
},
{
"datasource": "Loki",
"description": "",
"gridPos": {
"h": 10,
"w": 24,
"x": 0,
"y": 21
},
"id": 5,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": true,
"showTime": true,
"sortOrder": "Descending",
"wrapLogMessage": true
},
"pluginVersion": "7.3.6",
"targets": [
{
"expr": "{job=\"syslog\", host=~\"$host\"} |~ \"$free_form_filter\" |~ \"$filter\"",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Logs By Host - \"$filter\" - \"$free_form_filter\" (Filtered)",
"type": "logs"
}
],
"refresh": "30s",
"schemaVersion": 30,
"style": "dark",
"tags": [
"syslog"
],
"templating": {
"list": [
{
"allValue": null,
"current": {
"selected": true,
"text": [
"All"
],
"value": [
"$__all"
]
},
"datasource": "Loki",
"definition": "label_values({job=\"syslog\"}, host)",
"description": null,
"error": null,
"hide": 0,
"includeAll": true,
"label": "Host",
"multi": true,
"name": "host",
"options": [],
"query": "label_values({job=\"syslog\"}, host)",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 5,
"tagValuesQuery": "",
"type": "query"
},
{
"allValue": null,
"current": {
"selected": true,
"text": [
"All"
],
"value": [
"$__all"
]
},
"description": null,
"error": null,
"hide": 0,
"includeAll": true,
"label": "Filter",
"multi": true,
"name": "filter",
"options": [
{
"selected": true,
"text": "All",
"value": "$__all"
},
{
"selected": false,
"text": "info",
"value": "info"
},
{
"selected": false,
"text": "debug",
"value": "debug"
},
{
"selected": false,
"text": "warn",
"value": "warn"
},
{
"selected": false,
"text": "error",
"value": "error"
},
{
"selected": false,
"text": "ERR",
"value": "ERR"
},
{
"selected": false,
"text": "DNS",
"value": "DNS"
},
{
"selected": false,
"text": "auth_failures",
"value": "auth_failures"
},
{
"selected": false,
"text": "wpa_auth_failures",
"value": "wpa_auth_failures"
}
],
"query": "info,debug,warn,error,ERR,DNS,auth_failures,wpa_auth_failures",
"queryValue": "",
"skipUrlSync": false,
"type": "custom"
},
{
"current": {
"selected": true,
"text": "",
"value": ""
},
"description": null,
"error": null,
"hide": 0,
"label": "Free Form Filter",
"name": "free_form_filter",
"options": [
{
"selected": true,
"text": "",
"value": ""
}
],
"query": "",
"skipUrlSync": false,
"type": "textbox"
},
{
"allValue": null,
"current": {
"selected": false,
"text": "1m",
"value": "1m"
},
"description": null,
"error": null,
"hide": 0,
"includeAll": false,
"label": "Smooth",
"multi": false,
"name": "smooth",
"options": [
{
"selected": false,
"text": "30s",
"value": "30s"
},
{
"selected": true,
"text": "1m",
"value": "1m"
},
{
"selected": false,
"text": "2m",
"value": "2m"
},
{
"selected": false,
"text": "5m",
"value": "5m"
},
{
"selected": false,
"text": "10m",
"value": "10m"
},
{
"selected": false,
"text": "15m",
"value": "15m"
},
{
"selected": false,
"text": "30m",
"value": "30m"
},
{
"selected": false,
"text": "1h",
"value": "1h"
},
{
"selected": false,
"text": "2h",
"value": "2h"
}
],
"query": "30s,1m,2m,5m,10m,15m,30m,1h,2h",
"queryValue": "",
"skipUrlSync": false,
"type": "custom"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Loki Syslog AIO - Overview",
"uid": "lux4rd0labs_loki_syslog_aio_01",
"version": 4
}

View File

@@ -0,0 +1,12 @@
apiVersion: 1
providers:
- name: 'NoFolderDashboards'
orgId: 1
folder: ''
type: file
disableDeletion: false
editable: true
updateIntervalSeconds: 10
options:
path: /var/lib/grafana/dashboards/no_folder

View File

@@ -0,0 +1,12 @@
apiVersion: 1
providers:
- name: 'PerformanceOverviewDashboards'
orgId: 1
folder: 'Performance Overview'
type: file
disableDeletion: false
editable: true
updateIntervalSeconds: 10
options:
path: /var/lib/grafana/dashboards/performance_overview

View File

@@ -0,0 +1,10 @@
apiVersion: 1
datasources:
-
access: proxy
basicAuth: false
jsonData:
maxLines: 1000
name: Loki
type: loki
url: "http://loki:3100/"

View File

@@ -0,0 +1,8 @@
apiVersion: 1
datasources:
-
access: proxy
basicAuth: false
name: Prometheus
type: prometheus
url: "http://prometheus:9090/"

View File

@@ -0,0 +1,64 @@
auth_enabled: false
server:
http_listen_port: 3100
ingester:
lifecycler:
address: 127.0.0.1
ring:
kvstore:
store: inmemory
replication_factor: 1
final_sleep: 0s
chunk_idle_period: 1h # Any chunk not receiving new logs in this time will be flushed
max_chunk_age: 1h # All chunks will be flushed when they hit this age, default is 1h
chunk_target_size: 1048576 # Loki will attempt to build chunks up to 1.5MB, flushing first if chunk_idle_period or max_chunk_age is reached first
chunk_retain_period: 30s # Must be greater than index read cache TTL if using an index cache (Default index read cache TTL is 5m)
max_transfer_retries: 0 # Chunk transfers disabled
schema_config:
configs:
- from: 2020-10-24
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h
storage_config:
boltdb_shipper:
active_index_directory: /tmp/loki/boltdb-shipper-active
cache_location: /tmp/loki/boltdb-shipper-cache
cache_ttl: 24h # Can be increased for faster performance over longer query periods, uses more disk space
shared_store: filesystem
filesystem:
directory: /tmp/loki/chunks
compactor:
working_directory: /tmp/loki/boltdb-shipper-compactor
shared_store: filesystem
limits_config:
reject_old_samples: true
reject_old_samples_max_age: 168h
chunk_store_config:
max_look_back_period: 0s
table_manager:
retention_deletes_enabled: false
retention_period: 0s
ruler:
storage:
type: local
local:
directory: /tmp/loki/rules
rule_path: /tmp/loki/rules-temp
alertmanager_url: http://localhost:9093
ring:
kvstore:
store: inmemory
enable_api: true

View File

@@ -0,0 +1,79 @@
auth_enabled: false
server:
http_listen_port: 3100
ingester:
lifecycler:
address: 127.0.0.1
ring:
kvstore:
store: inmemory
replication_factor: 1
final_sleep: 0s
chunk_idle_period: 5m # Any chunk not receiving new logs in this time will be flushed (set very low just to push data into s3 exampe)
max_chunk_age: 10m # All chunks will be flushed when they hit this age, default is 1h
chunk_target_size: 1048576 # Loki will attempt to build chunks up to 1.5MB, flushing first if chunk_idle_period or max_chunk_age is reached first
chunk_retain_period: 30s # Must be greater than index read cache TTL if using an index cache (Default index read cache TTL is 5m)
max_transfer_retries: 0 # Chunk transfers disabled
schema_config:
configs:
- from: 2020-10-24
store: boltdb-shipper
object_store: s3
schema: v11
index:
prefix: index_
period: 24h
storage_config:
boltdb_shipper:
shared_store: s3
active_index_directory: /tmp/loki/index
cache_location: /tmp/loki/boltdb-cache
aws:
s3: s3://minio123:minio456@minio.:9000/loki
s3forcepathstyle: true
compactor:
working_directory: /tmp/loki/compactor
shared_store: s3
limits_config:
reject_old_samples: true
reject_old_samples_max_age: 168h
chunk_store_config:
max_look_back_period: 48h
table_manager:
retention_deletes_enabled: true
retention_period: 48h
query_range:
align_queries_with_step: true
max_retries: 5
split_queries_by_interval: 15m
parallelise_shardable_queries: true
cache_results: true
results_cache:
cache:
enable_fifocache: true
fifocache:
size: 1024
validity: 24h
ruler:
storage:
type: local
local:
directory: /tmp/loki/rules
rule_path: /tmp/loki/rules-temp
alertmanager_url: http://localhost:9093
ring:
kvstore:
store: inmemory
enable_api: true

View File

@@ -0,0 +1,47 @@
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
external_labels:
origin_prometheus: aio
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['prometheus:9090']
- job_name: 'grafana'
static_configs:
- targets: ['grafana:3000']
- job_name: 'loki'
static_configs:
- targets: ['loki:3100']
- job_name: 'promtail'
static_configs:
- targets: ['promtail:9080']
- job_name: 'minio'
metrics_path: /minio/prometheus/metrics
static_configs:
- targets: ['minio:9000']
- job_name: 'node'
static_configs:
- targets: ['node-exporter:9100']
- job_name: 'caadvisor'
static_configs:
- targets: ['cadvisor:8080']

View File

@@ -0,0 +1,22 @@
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
- url: http://loki:3100/loki/api/v1/push
scrape_configs:
- job_name: syslog
syslog:
listen_address: 0.0.0.0:1514
idle_timeout: 60s
label_structured_data: yes
labels:
job: "syslog"
relabel_configs:
- source_labels: ['__syslog_message_hostname']
target_label: 'host'

View File

@@ -0,0 +1,42 @@
#############################################################################
# Default syslog-ng.conf file which collects all local logs into a
# single file called /var/log/messages tailored to container usage.
#
# The changes from the stock, default syslog-ng.conf file is that we've
# dropped the system() source that is not needed and that we enabled network
# connections using default-network-drivers(). Customize as needed and
# override using the -v option to docker, such as:
#
# docker run ... -v "$PWD/syslog-ng.conf":/etc/syslog-ng/syslog-ng.conf
#
@version: 3.29
@include "scl.conf"
source s_local {
internal();
};
source s_network {
default-network-drivers(
# NOTE: TLS support
#
# the default-network-drivers() source driver opens the TLS
# enabled ports as well, however without an actual key/cert
# pair they will not operate and syslog-ng would display a
# warning at startup.
#
#tls(key-file("/path/to/ssl-private-key") cert-file("/path/to/ssl-cert"))
);
};
destination d_loki {
syslog("promtail" transport("tcp") port("1514"));
};
log {
source(s_local);
source(s_network);
destination(d_loki);
};

View File

@@ -0,0 +1,71 @@
networks:
loki: {}
services:
grafana:
container_name: grafana
environment:
GF_AUTH_ANONYMOUS_ENABLED: "true"
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
GF_AUTH_BASIC_ENABLED: "false"
GF_AUTH_DISABLE_LOGIN_FORM: "true"
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: /var/lib/grafana/dashboards/no_folder/loki_syslog_aio_overview.json
image: grafana/grafana:8.1.2
networks:
loki: null
ports:
- protocol: tcp
published: 3000
target: 3000
restart: always
volumes:
- ./config/grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro
- ./config/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./config/grafana/dashboards:/var/lib/grafana/dashboards:ro
loki:
command: -config.file=/etc/loki/loki-config.yml
container_name: loki
image: grafana/loki:2.3.0
networks:
loki: null
ports:
- protocol: tcp
published: 3100
target: 3100
restart: always
volumes:
- ./config/loki-config-filesystem.yml:/etc/loki/loki-config.yml:ro
promtail:
command: -config.file=/etc/promtail/promtail-config.yml
container_name: promtail
image: grafana/promtail:2.3.0
networks:
loki: null
ports:
- protocol: tcp
published: 1514
target: 1514
- protocol: tcp
published: 9080
target: 9080
restart: always
volumes:
- ./config/promtail-config.yml:/etc/promtail/promtail-config.yml:ro
syslog-ng:
command: -edv
container_name: syslog-ng
depends_on:
- promtail
image: balabit/syslog-ng:latest
networks:
loki: null
ports:
- protocol: udp
published: 514
target: 514
- protocol: tcp
published: 601
target: 601
restart: always
volumes:
- ./config/syslog-ng.conf:/etc/syslog-ng/syslog-ng.conf:ro
version: '3.3'

View File

@@ -0,0 +1,148 @@
networks:
loki: {}
services:
cadvisor:
container_name: cadvisor
image: gcr.io/cadvisor/cadvisor:latest
networks:
loki: null
ports:
- published: 8080
target: 8080
restart: always
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker:/var/lib/docker:ro
generator:
build:
context: ./generator
container_name: generator
depends_on:
- syslog-ng
networks:
loki: null
grafana:
container_name: grafana
environment:
GF_AUTH_ANONYMOUS_ENABLED: "true"
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
GF_AUTH_BASIC_ENABLED: "false"
GF_AUTH_DISABLE_LOGIN_FORM: "true"
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: /var/lib/grafana/dashboards/no_folder/loki_syslog_aio_overview.json
image: grafana/grafana:8.1.2
networks:
loki: null
ports:
- protocol: tcp
published: 3000
target: 3000
restart: always
volumes:
- ./config/grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro
- ./config/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./config/grafana/dashboards:/var/lib/grafana/dashboards:ro
loki:
command: -config.file=/etc/loki/loki-config.yml
container_name: loki
depends_on:
- minio
image: grafana/loki:2.3.0
networks:
loki: null
ports:
- protocol: tcp
published: 3100
target: 3100
restart: always
volumes:
- ./config/loki-config-s3.yml:/etc/loki/loki-config.yml:ro
minio:
command: -c 'mkdir -p /data/loki && /usr/bin/docker-entrypoint.sh minio server /data'
container_name: minio
entrypoint: sh
environment:
MINIO_ACCESS_KEY: minio123
MINIO_PROMETHEUS_AUTH_TYPE: public
MINIO_SECRET_KEY: minio456
healthcheck:
interval: 30s
retries: 3
test:
- CMD
- curl
- -f
- http://localhost:9000/minio/health/live
timeout: 20s
image: minio/minio:latest
networks:
loki: null
ports:
- published: 9000
target: 9000
restart: always
node-exporter:
command: --path.rootfs=/host
container_name: node-exporter
image: prom/node-exporter:latest
networks:
loki: null
pid: host
ports:
- published: 9100
target: 9100
restart: always
volumes:
- /:/host:ro,rslave
prometheus:
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --web.enable-admin-api
- --web.enable-lifecycle
container_name: prometheus
image: prom/prometheus:latest
networks:
loki: null
ports:
- published: 9090
target: 9090
restart: always
volumes:
- ./config/prometheus.yml:/etc/prometheus/prometheus.yml:ro
promtail:
command: -config.file=/etc/promtail/promtail-config.yml
container_name: promtail
image: grafana/promtail:2.3.0
networks:
loki: null
ports:
- protocol: tcp
published: 1514
target: 1514
- protocol: tcp
published: 9080
target: 9080
restart: always
volumes:
- ./config/promtail-config.yml:/etc/promtail/promtail-config.yml:ro
syslog-ng:
command: -edv
container_name: syslog-ng
depends_on:
- promtail
image: balabit/syslog-ng:latest
networks:
loki: null
ports:
- protocol: udp
published: 514
target: 514
- protocol: tcp
published: 601
target: 601
restart: always
volumes:
- ./config/syslog-ng.conf:/etc/syslog-ng/syslog-ng.conf:ro
version: '3.3'

View File

@@ -0,0 +1,97 @@
networks:
loki: {}
services:
grafana:
container_name: grafana
environment:
GF_AUTH_ANONYMOUS_ENABLED: "true"
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
GF_AUTH_BASIC_ENABLED: "false"
GF_AUTH_DISABLE_LOGIN_FORM: "true"
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: /var/lib/grafana/dashboards/no_folder/loki_syslog_aio_overview.json
image: grafana/grafana:8.1.2
networks:
loki: null
ports:
- protocol: tcp
published: 3000
target: 3000
restart: always
volumes:
- ./config/grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro
- ./config/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./config/grafana/dashboards:/var/lib/grafana/dashboards:ro
loki:
command: -config.file=/etc/loki/loki-config.yml
container_name: loki
depends_on:
- minio
image: grafana/loki:2.3.0
networks:
loki: null
ports:
- protocol: tcp
published: 3100
target: 3100
restart: always
volumes:
- ./config/loki-config-s3.yml:/etc/loki/loki-config.yml:ro
minio:
command: -c 'mkdir -p /data/loki && /usr/bin/docker-entrypoint.sh minio server /data'
container_name: minio
entrypoint: sh
environment:
MINIO_ACCESS_KEY: minio123
MINIO_PROMETHEUS_AUTH_TYPE: public
MINIO_SECRET_KEY: minio456
healthcheck:
interval: 30s
retries: 3
test:
- CMD
- curl
- -f
- http://localhost:9000/minio/health/live
timeout: 20s
image: minio/minio:latest
networks:
loki: null
ports:
- published: 9000
target: 9000
restart: always
promtail:
command: -config.file=/etc/promtail/promtail-config.yml
container_name: promtail
image: grafana/promtail:2.3.0
networks:
loki: null
ports:
- protocol: tcp
published: 1514
target: 1514
- protocol: tcp
published: 9080
target: 9080
restart: always
volumes:
- ./config/promtail-config.yml:/etc/promtail/promtail-config.yml:ro
syslog-ng:
command: -edv
container_name: syslog-ng
depends_on:
- promtail
image: balabit/syslog-ng:latest
networks:
loki: null
ports:
- protocol: udp
published: 514
target: 514
- protocol: tcp
published: 601
target: 601
restart: always
volumes:
- ./config/syslog-ng.conf:/etc/syslog-ng/syslog-ng.conf:ro
version: '3.3'

View File

@@ -0,0 +1,169 @@
networks:
loki: {}
services:
cadvisor:
container_name: cadvisor
image: gcr.io/cadvisor/cadvisor:latest
networks:
loki: null
ports:
- published: 8088
target: 8088
restart: always
logging:
driver: "json-file"
options:
max-size: "50m"
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker:/var/lib/docker:ro
grafana:
container_name: grafana
environment:
GF_AUTH_ANONYMOUS_ENABLED: "true"
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
GF_AUTH_BASIC_ENABLED: "false"
GF_AUTH_DISABLE_LOGIN_FORM: "true"
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: /var/lib/grafana/dashboards/no_folder/loki_syslog_aio_overview.json
GF_INSTALL_PLUGINS: alexanderzobnin-zabbix-app
image: grafana/grafana:latest
networks:
loki: null
ports:
- protocol: tcp
published: 3000
target: 3000
restart: always
logging:
driver: "json-file"
options:
max-size: "50m"
volumes:
- ./config/grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro
- ./config/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./config/grafana/dashboards:/var/lib/grafana/dashboards:ro
loki:
command: -config.file=/etc/loki/loki-config.yml
container_name: loki
depends_on:
- minio
image: grafana/loki:2.3.0
networks:
loki: null
ports:
- protocol: tcp
published: 3100
target: 3100
restart: always
logging:
driver: "json-file"
options:
max-size: "50m"
volumes:
- ./config/loki-config-s3.yml:/etc/loki/loki-config.yml:ro
minio:
command: -c 'mkdir -p /data/loki && /usr/bin/docker-entrypoint.sh minio server /data'
container_name: minio
entrypoint: sh
environment:
MINIO_ACCESS_KEY: minio123
MINIO_PROMETHEUS_AUTH_TYPE: public
MINIO_SECRET_KEY: minio456
healthcheck:
interval: 30s
retries: 3
test:
- CMD
- curl
- -f
- http://localhost:9000/minio/health/live
timeout: 20s
image: minio/minio:latest
networks:
loki: null
ports:
- published: 9000
target: 9000
restart: always
logging:
driver: "json-file"
options:
max-size: "50m"
node-exporter:
command: --path.rootfs=/host/root
container_name: node-exporter
image: prom/node-exporter:latest
networks:
loki: null
pid: host
ports:
- published: 9100
target: 9100
restart: always
logging:
driver: "json-file"
options:
max-size: "50m"
volumes:
- /:/host:ro
prometheus:
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --web.enable-admin-api
- --web.enable-lifecycle
container_name: prometheus
image: prom/prometheus:latest
networks:
loki: null
ports:
- published: 9091
target: 9091
restart: always
logging:
driver: "json-file"
options:
max-size: "50m"
volumes:
- ./config/prometheus.yml:/etc/prometheus/prometheus.yml:ro
promtail:
command: -config.file=/etc/promtail/promtail-config.yml
container_name: promtail
image: grafana/promtail:2.3.0
networks:
loki: null
ports:
- protocol: tcp
published: 1514
target: 1514
- protocol: tcp
published: 9080
target: 9080
restart: always
logging:
driver: "json-file"
options:
max-size: "50m"
volumes:
- ./config/promtail-config.yml:/etc/promtail/promtail-config.yml:ro
syslog-ng:
command: -edv
container_name: syslog-ng
depends_on:
- promtail
image: balabit/syslog-ng:latest
networks:
loki: null
ports:
- protocol: udp
published: 514
target: 514
- protocol: tcp
published: 601
target: 601
restart: always
volumes:
- ./config/syslog-ng.conf:/etc/syslog-ng/syslog-ng.conf:ro
version: '3.3'

View File

@@ -0,0 +1,7 @@
FROM grafana/promtail:2.3.0
RUN apt-get update && apt-get install -y netcat bc curl dumb-init bash procps coreutils vim net-tools
COPY ./entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
CMD [ "10", "500" ]

View File

@@ -0,0 +1,3 @@
docker build -t docker01.tylephony.com:5000/lux4rd0/syslog-generator:latest -f Dockerfile --no-cache .
docker push docker01.tylephony.com:5000/lux4rd0/syslog-generator:latest

View File

@@ -0,0 +1,39 @@
#!/bin/bash
n=-1
c=0
if [ -n "$3" ]
then
n=$3
fi
endpoint="syslog-ng"
while [ "$n" -ne $c ]
do
arr[0]="loki.grafana.com"
arr[1]="tempo.grafana.com"
arr[2]="grafana.grafana.com"
arr[3]="prometheus.grafana.com"
arr[4]="cortex.grafana.com"
arr[5]="tanka.grafana.com"
rand=$[$RANDOM % ${#arr[@]}]
random_host=${arr[$rand]}
WAIT=$(shuf -i "$1"-"$2" -n 1)
sleep $(echo "scale=4; $WAIT/1000" | bc)
I=$(shuf -i 1-4 -n 1)
D=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
case "$I" in
"1") echo "$D ${random_host} ERROR An error is usually an exception that has been caught and not handled." | nc -u -w1 ${endpoint} 514
;;
"2") echo "$D ${random_host} INFO An info is often used to provide context in the current task." | nc -u -w1 ${endpoint} 514
;;
"3") echo "$D ${random_host} WARN A warning that should be ignored is usually at this level and should be actionable." | nc -u -w1 ${endpoint} 514
;;
"4") echo "$D ${random_host} DEBUG This is a debug log that shows a log that can be ignored." | nc -u -w1 ${endpoint} 514
;;
esac
c=$(( c+1 ))
done

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 KiB