Compare commits
47 Commits
20230625-1
...
2024.0114.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0e3512a23 | ||
|
|
6ecc586aaa | ||
|
|
b84d19d11f | ||
|
|
d471db7f6c | ||
|
|
c198541542 | ||
|
|
f6d3341085 | ||
|
|
5274fd73f2 | ||
|
|
01798bb978 | ||
|
|
70b6aed937 | ||
|
|
488f8e4aa2 | ||
|
|
a4634a63b2 | ||
|
|
8b327fdbab | ||
|
|
e849e933a0 | ||
|
|
bf9f639dce | ||
|
|
c14ce15f5d | ||
|
|
0b504445ea | ||
|
|
553324103e | ||
|
|
46dd8a04d2 | ||
|
|
a0992a39e4 | ||
|
|
c27487330e | ||
|
|
bacd610e7d | ||
|
|
38fbd4ead9 | ||
|
|
f3c55a99c2 | ||
|
|
1f725a816f | ||
|
|
6e4e588bec | ||
|
|
9aee12a948 | ||
|
|
763d57d142 | ||
|
|
8c80934f70 | ||
|
|
971f1cc9c4 | ||
|
|
7b8a219237 | ||
|
|
0c155736b5 | ||
|
|
af349be575 | ||
|
|
439482cc04 | ||
|
|
e6f0ad39db | ||
|
|
7c4d2eac3c | ||
|
|
e85b925581 | ||
|
|
0b5b6818ad | ||
|
|
07612794be | ||
|
|
e2c7a199d2 | ||
|
|
b2a0c3885c | ||
|
|
7346a983e8 | ||
|
|
e2a643ddaf | ||
|
|
bd349e28f8 | ||
|
|
1683280c45 | ||
|
|
58c6aa5702 | ||
|
|
b362647ef3 | ||
|
|
f1d4f43fc7 |
22
.github/workflows/docker-hub-description.yml
vendored
Normal file
22
.github/workflows/docker-hub-description.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
name: Update Docker Hub description
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- created
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: Update Docker Hub description
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
- name: Update Docker Hub description
|
||||
uses: peter-evans/dockerhub-description@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
repository: ${{ github.repository }}
|
||||
short-description: ${{ github.event.repository.description }}
|
||||
73
.github/workflows/on-push-main.yml
vendored
73
.github/workflows/on-push-main.yml
vendored
@@ -14,42 +14,67 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Extract tag string
|
||||
id: git
|
||||
shell: bash
|
||||
run: |
|
||||
RELEASE_VERSION="dev-$(date +%s)"
|
||||
echo "image_tag=${RELEASE_VERSION}" >> ${GITHUB_OUTPUT}
|
||||
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Install buildx
|
||||
uses: docker/setup-buildx-action@v2.7.0
|
||||
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.0.0
|
||||
- name: Login to docker hub
|
||||
uses: docker/login-action@v2.2.0
|
||||
uses: docker/login-action@v3.0.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2.2.0
|
||||
uses: docker/login-action@v3.0.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ github.token }}
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
${{ github.repository }}
|
||||
ghcr.io/${{ github.repository }}
|
||||
tags: |
|
||||
type=raw,value=dev-{{date 'X'}}
|
||||
type=raw,value=development
|
||||
type=ref,event=branch
|
||||
type=edge,branch=main
|
||||
- name: Build and push ${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
||||
uses: docker/build-push-action@v4.1.1
|
||||
uses: docker/build-push-action@v5.1.0
|
||||
with:
|
||||
platforms: ${{ env.PLATFORMS }}
|
||||
push: true
|
||||
tags: |
|
||||
${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
||||
${{ github.repository }}:development
|
||||
ghcr.io/${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
||||
ghcr.io/${{ github.repository }}:development
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
provenance: false
|
||||
|
||||
clean-ghcr:
|
||||
name: Delete old dev container images
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Delete old dev images
|
||||
uses: snok/container-retention-policy@v2
|
||||
with:
|
||||
image-names: endlessh-go
|
||||
cut-off: One day ago UTC
|
||||
account-type: personal
|
||||
token: ${{ secrets.TOKEN_DELETE_GHCR_IMAGES }}
|
||||
keep-at-least: 5
|
||||
skip-tags: latest, development
|
||||
filter-tags: "dev-*"
|
||||
dry-run: False
|
||||
- name: Delete untagged images
|
||||
uses: snok/container-retention-policy@v2
|
||||
with:
|
||||
image-names: endlessh-go
|
||||
cut-off: One hour ago UTC
|
||||
account-type: personal
|
||||
token: ${{ secrets.TOKEN_DELETE_GHCR_IMAGES }}
|
||||
keep-at-least: 0
|
||||
untagged-only: True
|
||||
skip-tags: latest, development
|
||||
dry-run: False
|
||||
|
||||
|
||||
54
.github/workflows/on-release.yml
vendored
54
.github/workflows/on-release.yml
vendored
@@ -13,49 +13,37 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Extract tag string
|
||||
id: git
|
||||
shell: bash
|
||||
run: |
|
||||
RELEASE_VERSION=${GITHUB_REF#refs/*/}
|
||||
echo "image_tag=${RELEASE_VERSION}" >> ${GITHUB_OUTPUT}
|
||||
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Install buildx
|
||||
uses: docker/setup-buildx-action@v2.7.0
|
||||
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.0.0
|
||||
- name: Login to docker hub
|
||||
uses: docker/login-action@v2.2.0
|
||||
uses: docker/login-action@v3.0.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2.2.0
|
||||
uses: docker/login-action@v3.0.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ github.token }}
|
||||
|
||||
- name: Build and push ${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
||||
uses: docker/build-push-action@v4.1.1
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
${{ github.repository }}
|
||||
ghcr.io/${{ github.repository }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5.1.0
|
||||
with:
|
||||
platforms: ${{ env.PLATFORMS }}
|
||||
push: true
|
||||
tags: |
|
||||
${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
||||
${{ github.repository }}:latest
|
||||
ghcr.io/${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
||||
ghcr.io/${{ github.repository }}:latest
|
||||
|
||||
- name: Update dockerhub description
|
||||
uses: peter-evans/dockerhub-description@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
repository: ${{ github.repository }}
|
||||
short-description: ${{ github.event.repository.description }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
provenance: false
|
||||
|
||||
@@ -3,9 +3,8 @@ FROM golang AS build
|
||||
RUN mkdir /endlessh
|
||||
ADD . /endlessh
|
||||
WORKDIR /endlessh
|
||||
RUN CGO_ENABLED=1
|
||||
RUN go mod tidy
|
||||
RUN go build -o endlessh .
|
||||
RUN CGO_ENABLED=0 go build -o endlessh .
|
||||
|
||||
FROM gcr.io/distroless/base
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ A golang implementation of [endlessh](https://nullprogram.com/blog/2019/03/22/)
|
||||
|
||||
## Introduction
|
||||
|
||||
Endlessh is a great idea that not only blocks the brute force SSH attacks, but also wastes attackers time as a kind of counter-attack. Besides trapping the attackers, I also want to visualize the Geolocations and other statistics of the sources of attacks. Unfortunately the wonderful original [C implementation of endlessh](https://github.com/skeeto/endlessh) only provides text based log, but I do not like the solution that writing extra scripts to parse the log outputs, then exporting the results to a dashboard, because it would introduce extra layers in my current setup and it would depend on the format of the text log file rather than some structured data. Thus I create this golang implementation of endlessh to export [Prometheus](https://prometheus.io/) metrics and a [Grafana](https://grafana.com/) dashboard to visualize them.
|
||||
[Endlessh](https://nullprogram.com/blog/2019/03/22/) is a great idea that not only blocks the brute force SSH attacks, but also wastes attackers time as a kind of counter-attack. Besides trapping the attackers, I also want to visualize the Geolocations and other statistics of the sources of attacks. Unfortunately the wonderful original [C implementation of endlessh](https://github.com/skeeto/endlessh) only provides text based log, but I do not like the solution that writes extra scripts to parse the log outputs, then exports the results to a dashboard, because it would introduce extra layers in my current setup and it would depend on the format of the text log file rather than some structured data. Thus I create this golang implementation of endlessh to export [Prometheus](https://prometheus.io/) metrics and a [Grafana](https://grafana.com/) dashboard to visualize them.
|
||||
|
||||
If you want a dashboard of sources of attacks and do not mind the endlessh server, besides trapping the attackers, does extra things including: translating IP to Geohash, exporting Prometheus metrics, and using more memory (about 10MB), this is the solution for you.
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"type": "grafana",
|
||||
"id": "grafana",
|
||||
"name": "Grafana",
|
||||
"version": "9.3.6"
|
||||
"version": "10.3.0-64399"
|
||||
},
|
||||
{
|
||||
"type": "panel",
|
||||
@@ -76,7 +76,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"description": "Dashboard for endlessh (Update variables on time range changes)",
|
||||
"description": "Dashboard for endlessh (Load metrics at the first panel instead of the last panel)",
|
||||
"editable": false,
|
||||
"fiscalYearStartMonth": 0,
|
||||
"gnetId": 15156,
|
||||
@@ -112,8 +112,8 @@
|
||||
"panels": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "-- Dashboard --"
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
@@ -140,6 +140,8 @@
|
||||
"y": 0
|
||||
},
|
||||
"id": 36,
|
||||
"interval": "1m",
|
||||
"maxDataPoints": 1440,
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "none",
|
||||
@@ -153,17 +155,37 @@
|
||||
"values": false
|
||||
},
|
||||
"text": {},
|
||||
"textMode": "auto"
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
},
|
||||
"pluginVersion": "9.3.6",
|
||||
"pluginVersion": "10.3.0-64399",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "-- Dashboard --"
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"panelId": 49,
|
||||
"refId": "A"
|
||||
"editorMode": "code",
|
||||
"expr": "(endlessh_client_open_count{instance=~\"$host\",job=~\"$job\"} - endlessh_client_open_count{instance=~\"$host\",job=~\"$job\"} offset $__interval) > 0 or (endlessh_client_open_count{instance=~\"$host\",job=~\"$job\"}!=0 unless endlessh_client_open_count{instance=~\"$host\",job=~\"$job\"} offset $__interval)",
|
||||
"format": "table",
|
||||
"instant": false,
|
||||
"legendFormat": "Seen {{ip}}",
|
||||
"range": true,
|
||||
"refId": "Seen"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"editorMode": "code",
|
||||
"expr": "(endlessh_client_trapped_time_seconds{instance=~\"$host\",job=~\"$job\"} - endlessh_client_trapped_time_seconds{instance=~\"$host\",job=~\"$job\"} offset $__interval) > 0 or (endlessh_client_trapped_time_seconds{instance=~\"$host\",job=~\"$job\"}!=0 unless endlessh_client_trapped_time_seconds{instance=~\"$host\",job=~\"$job\"} offset $__interval)",
|
||||
"format": "table",
|
||||
"hide": false,
|
||||
"instant": false,
|
||||
"legendFormat": "Trapped {{ip}}",
|
||||
"range": true,
|
||||
"refId": "Trapped"
|
||||
}
|
||||
],
|
||||
"title": "Connections",
|
||||
@@ -277,16 +299,17 @@
|
||||
"values": false
|
||||
},
|
||||
"text": {},
|
||||
"textMode": "auto"
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
},
|
||||
"pluginVersion": "9.3.6",
|
||||
"pluginVersion": "10.3.0-64399",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "-- Dashboard --"
|
||||
},
|
||||
"panelId": 49,
|
||||
"panelId": 36,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
@@ -402,9 +425,10 @@
|
||||
"values": false
|
||||
},
|
||||
"text": {},
|
||||
"textMode": "auto"
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
},
|
||||
"pluginVersion": "9.3.6",
|
||||
"pluginVersion": "10.3.0-64399",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
@@ -465,16 +489,17 @@
|
||||
"values": false
|
||||
},
|
||||
"text": {},
|
||||
"textMode": "auto"
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
},
|
||||
"pluginVersion": "9.3.6",
|
||||
"pluginVersion": "10.3.0-64399",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "-- Dashboard --"
|
||||
},
|
||||
"panelId": 49,
|
||||
"panelId": 36,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
@@ -578,16 +603,17 @@
|
||||
"values": false
|
||||
},
|
||||
"text": {},
|
||||
"textMode": "value"
|
||||
"textMode": "value",
|
||||
"wideLayout": true
|
||||
},
|
||||
"pluginVersion": "9.3.6",
|
||||
"pluginVersion": "10.3.0-64399",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "-- Dashboard --"
|
||||
},
|
||||
"panelId": 49,
|
||||
"panelId": 36,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
@@ -722,9 +748,10 @@
|
||||
"values": false
|
||||
},
|
||||
"text": {},
|
||||
"textMode": "auto"
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
},
|
||||
"pluginVersion": "9.3.6",
|
||||
"pluginVersion": "10.3.0-64399",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
@@ -753,6 +780,7 @@
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisBorderShow": false,
|
||||
"axisCenteredZero": false,
|
||||
"axisColorMode": "text",
|
||||
"axisLabel": "",
|
||||
@@ -766,6 +794,7 @@
|
||||
"tooltip": false,
|
||||
"viz": false
|
||||
},
|
||||
"insertNulls": false,
|
||||
"lineInterpolation": "stepAfter",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
@@ -886,7 +915,7 @@
|
||||
"type": "datasource",
|
||||
"uid": "-- Dashboard --"
|
||||
},
|
||||
"panelId": 49,
|
||||
"panelId": 36,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
@@ -1068,14 +1097,14 @@
|
||||
"zoom": 1
|
||||
}
|
||||
},
|
||||
"pluginVersion": "9.3.6",
|
||||
"pluginVersion": "10.3.0-64399",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "-- Dashboard --"
|
||||
},
|
||||
"panelId": 49,
|
||||
"panelId": 36,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
@@ -1151,8 +1180,8 @@
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
"type": "datasource",
|
||||
"uid": "-- Dashboard --"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
@@ -1161,7 +1190,9 @@
|
||||
},
|
||||
"custom": {
|
||||
"align": "auto",
|
||||
"displayMode": "auto",
|
||||
"cellOptions": {
|
||||
"type": "auto"
|
||||
},
|
||||
"filterable": true,
|
||||
"inspect": false,
|
||||
"minWidth": 50
|
||||
@@ -1239,7 +1270,9 @@
|
||||
},
|
||||
"id": 49,
|
||||
"options": {
|
||||
"cellHeight": "sm",
|
||||
"footer": {
|
||||
"countRows": false,
|
||||
"fields": "",
|
||||
"reducer": [
|
||||
"sum"
|
||||
@@ -1255,33 +1288,15 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"pluginVersion": "9.3.6",
|
||||
"pluginVersion": "10.3.0-64399",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
"type": "datasource",
|
||||
"uid": "-- Dashboard --"
|
||||
},
|
||||
"exemplar": true,
|
||||
"expr": "(endlessh_client_open_count{instance=~\"$host\",job=~\"$job\"} - endlessh_client_open_count{instance=~\"$host\",job=~\"$job\"} offset $__interval) > 0 or (endlessh_client_open_count{instance=~\"$host\",job=~\"$job\"}!=0 unless endlessh_client_open_count{instance=~\"$host\",job=~\"$job\"} offset $__interval)",
|
||||
"format": "table",
|
||||
"hide": false,
|
||||
"interval": "",
|
||||
"legendFormat": "Seen {{ip}}",
|
||||
"refId": "Seen"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "${DS_PROMETHEUS}"
|
||||
},
|
||||
"exemplar": true,
|
||||
"expr": "(endlessh_client_trapped_time_seconds{instance=~\"$host\",job=~\"$job\"} - endlessh_client_trapped_time_seconds{instance=~\"$host\",job=~\"$job\"} offset $__interval) > 0 or (endlessh_client_trapped_time_seconds{instance=~\"$host\",job=~\"$job\"}!=0 unless endlessh_client_trapped_time_seconds{instance=~\"$host\",job=~\"$job\"} offset $__interval)",
|
||||
"format": "table",
|
||||
"hide": false,
|
||||
"interval": "",
|
||||
"legendFormat": "Trapped {{ip}}",
|
||||
"refId": "Trapped"
|
||||
"panelId": 36,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Clients",
|
||||
@@ -1446,8 +1461,7 @@
|
||||
}
|
||||
],
|
||||
"refresh": "",
|
||||
"schemaVersion": 37,
|
||||
"style": "dark",
|
||||
"schemaVersion": 39,
|
||||
"tags": [
|
||||
"prometheus"
|
||||
],
|
||||
@@ -1511,6 +1525,6 @@
|
||||
"timezone": "",
|
||||
"title": "Endlessh",
|
||||
"uid": "ATIxYkO7k",
|
||||
"version": 10,
|
||||
"version": 6,
|
||||
"weekStart": ""
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
> The default container user has uid 65534.
|
||||
|
||||
## docker-simple
|
||||
## [docker-simple](./docker-simple)
|
||||
|
||||
An example how to setup endlessh-go, Prometheus, and Grafana using [docker compose](https://docs.docker.com/compose/).
|
||||
|
||||
## docker-maxmind
|
||||
## [docker-maxmind](./docker-maxmind)
|
||||
|
||||
An example how to setup endlessh-go with the Maxmind GeoIP Database.
|
||||
|
||||
|
||||
19
go.mod
19
go.mod
@@ -3,21 +3,20 @@ module endlessh-go
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/golang/glog v1.1.1
|
||||
github.com/golang/glog v1.2.0
|
||||
github.com/oschwald/geoip2-golang v1.9.0
|
||||
github.com/pierrre/geohash v1.1.0
|
||||
github.com/prometheus/client_golang v1.16.0
|
||||
github.com/pierrre/geohash v1.1.1
|
||||
github.com/prometheus/client_golang v1.18.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
|
||||
github.com/oschwald/maxminddb-golang v1.11.0 // indirect
|
||||
github.com/prometheus/client_model v0.3.0 // indirect
|
||||
github.com/prometheus/common v0.42.0 // indirect
|
||||
github.com/prometheus/procfs v0.10.1 // indirect
|
||||
golang.org/x/sys v0.9.0 // indirect
|
||||
google.golang.org/protobuf v1.30.0 // indirect
|
||||
github.com/prometheus/client_model v0.5.0 // indirect
|
||||
github.com/prometheus/common v0.45.0 // indirect
|
||||
github.com/prometheus/procfs v0.12.0 // indirect
|
||||
golang.org/x/sys v0.15.0 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
)
|
||||
|
||||
51
go.sum
51
go.sum
@@ -7,42 +7,39 @@ github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj
|
||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/fanixk/geohash v0.0.0-20150324002647-c1f9b5fa157a h1:Fyfh/dsHFrC6nkX7H7+nFdTd1wROlX/FxEIWVpKYf1U=
|
||||
github.com/golang/glog v1.1.1 h1:jxpi2eWoU84wbX9iIEyAeeoac3FLuifZpY9tcNUD9kw=
|
||||
github.com/golang/glog v1.1.1/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||
github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68=
|
||||
github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg=
|
||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k=
|
||||
github.com/mmcloughlin/geohash v0.10.0 h1:9w1HchfDfdeLc+jFEf/04D27KP7E2QmpDu52wPbJWRE=
|
||||
github.com/oschwald/geoip2-golang v1.9.0 h1:uvD3O6fXAXs+usU+UGExshpdP13GAqp4GBrzN7IgKZc=
|
||||
github.com/oschwald/geoip2-golang v1.9.0/go.mod h1:BHK6TvDyATVQhKNbQBdrj9eAvuwOMi2zSFXizL3K81Y=
|
||||
github.com/oschwald/maxminddb-golang v1.11.0 h1:aSXMqYR/EPNjGE8epgqwDay+P30hCBZIveY0WZbAWh0=
|
||||
github.com/oschwald/maxminddb-golang v1.11.0/go.mod h1:YmVI+H0zh3ySFR3w+oz8PCfglAFj3PuCmui13+P9zDg=
|
||||
github.com/pierrre/compare v1.1.0 h1:57z388tk9GXcyLnLXh1pMRdCQrfUH056x9dyNCCZZtg=
|
||||
github.com/pierrre/geohash v1.1.0 h1:AeTekkssK2HV3le9vya4cVFIPMx60bVIHaTvC+/5vyc=
|
||||
github.com/pierrre/geohash v1.1.0/go.mod h1:QQAU8mXr7WIhJJqL2uAvhJHrMeH/jLeETutCqY/fDeU=
|
||||
github.com/pierrre/assert v0.3.2 h1:wXdlkVN5FVSLEKl6pGijcCYkldgfjRgyheU3C1/by9Q=
|
||||
github.com/pierrre/compare v1.4.2 h1:oabIiWclzAlXG7S/2MYSFDJ/vR34oa/MYrBZh5PNU80=
|
||||
github.com/pierrre/geohash v1.1.1 h1:XCkvOyv/uesenMPhkvsCfIiUalBmGdHlFY0bIWTqb+s=
|
||||
github.com/pierrre/geohash v1.1.1/go.mod h1:ucAm7cbgGBoVr6cr1t+d3ea5XQ9P5zKHXfS1Qy2iKVY=
|
||||
github.com/pierrre/go-libs v0.2.14 h1:wAPoOrslKLnha6ow5EKkxxZpo76kOea57efs71A/ZnQ=
|
||||
github.com/pierrre/pretty v0.0.10 h1:Cb5som+1EpU+x7UA5AMy9I8AY2XkzMBywkLEAdo1JDg=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8=
|
||||
github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc=
|
||||
github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4=
|
||||
github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
|
||||
github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM=
|
||||
github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
|
||||
github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg=
|
||||
github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM=
|
||||
github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk=
|
||||
github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA=
|
||||
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
|
||||
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
|
||||
github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM=
|
||||
github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY=
|
||||
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
|
||||
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/the42/cartconvert v0.0.0-20131203171324-aae784c392b8 h1:I4DY8wLxJXCrMYzDM6lKCGc3IQwJX0PlTLsd3nQqI3c=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
|
||||
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
github.com/the42/cartconvert v1.0.0 h1:g8kt6ic2GEhdcZ61ZP9GsWwhosVo5nCnH1n2/oAQXUU=
|
||||
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
|
||||
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
|
||||
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
|
||||
16
main.go
16
main.go
@@ -91,13 +91,15 @@ func initPrometheus(prometheusHost, prometheusPort, prometheusEntry string) {
|
||||
},
|
||||
[]string{"ip"},
|
||||
)
|
||||
prometheus.MustRegister(totalClients)
|
||||
prometheus.MustRegister(totalClientsClosed)
|
||||
prometheus.MustRegister(totalBytes)
|
||||
prometheus.MustRegister(totalSeconds)
|
||||
prometheus.MustRegister(clientIP)
|
||||
prometheus.MustRegister(clientSeconds)
|
||||
http.Handle("/"+prometheusEntry, promhttp.Handler())
|
||||
promReg := prometheus.NewRegistry()
|
||||
promReg.MustRegister(totalClients)
|
||||
promReg.MustRegister(totalClientsClosed)
|
||||
promReg.MustRegister(totalBytes)
|
||||
promReg.MustRegister(totalSeconds)
|
||||
promReg.MustRegister(clientIP)
|
||||
promReg.MustRegister(clientSeconds)
|
||||
handler := promhttp.HandlerFor(promReg, promhttp.HandlerOpts{EnableOpenMetrics: true})
|
||||
http.Handle("/"+prometheusEntry, handler)
|
||||
go func() {
|
||||
glog.Infof("Starting Prometheus on %v:%v, entry point is /%v", prometheusHost, prometheusPort, prometheusEntry)
|
||||
http.ListenAndServe(prometheusHost+":"+prometheusPort, nil)
|
||||
|
||||
Reference in New Issue
Block a user