Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7667d1b
add project v1.0.0
willowweevil Nov 27, 2025
3d132c3
ad CHANGELOG.md
willowweevil Dec 3, 2025
e5f6bd7
add LICENSE
willowweevil Dec 3, 2025
7d67a4e
add --rm flag to docker run
willowweevil Dec 3, 2025
7ab539a
add build-binary stage
willowweevil Dec 3, 2025
c05406f
update ci to run by pushing tag in main
willowweevil Dec 4, 2025
735a1f4
set build by tag from main/develop branches
willowweevil Dec 4, 2025
8263db4
update locations
willowweevil Dec 4, 2025
83eb9b8
add rate limits logic
willowweevil Dec 4, 2025
615f5ac
remove build-binary from needs in build stage
willowweevil Dec 4, 2025
0a35cbe
initialize v1.0.0
willowweevil Dec 5, 2025
0f25323
add branding materials
willowweevil Dec 5, 2025
31bd389
update metrics
willowweevil Dec 9, 2025
03fb871
update error metric
willowweevil Dec 9, 2025
d7349c3
add metrics labels
willowweevil Dec 9, 2025
d2e8951
update metrics
willowweevil Dec 9, 2025
6b057fc
update README.md
willowweevil Dec 9, 2025
07ffe44
add grafana dashboards
willowweevil Dec 9, 2025
8fa8e24
update README
willowweevil Dec 12, 2025
c43e1fe
update dashboards
willowweevil Dec 12, 2025
33fc8f9
add 'apatit_mp_data_status' metric
willowweevil Dec 12, 2025
dbb9ae5
add data status stat panel
willowweevil Dec 12, 2025
919781d
update ci
willowweevil Dec 12, 2025
66d6110
add helm-chart
willowweevil Dec 12, 2025
f3f0533
change version in arg
willowweevil Dec 12, 2025
a1c68db
add locations.json to release
willowweevil Dec 12, 2025
4453daf
update locations
willowweevil Dec 12, 2025
81b1839
fix 'status' metric name
willowweevil Dec 12, 2025
4e3a72f
update monitoring dashboard
willowweevil Dec 12, 2025
075169b
fix typo in REQUEST_DELAY env var; extend default delay up to 3s
willowweevil Dec 16, 2025
a354396
update README
willowweevil Dec 16, 2025
dbc234d
update goland and libaries
willowweevil Dec 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
---
name: CI

on:
push:
branches: [ "main" , "develop" ]
tags:
- 'v*'
pull_request:
branches: [ "main" ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
lint:
name: Lint Go Code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache: true

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: --timeout=5m

build-binary:
name: Build Binary for Linux AMD64
runs-on: ubuntu-latest
needs: lint
if: startsWith(github.ref, 'refs/tags/v')

permissions:
contents: write
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Verify tag is on main or develop branch
run: |
TAG_NAME="${GITHUB_REF#refs/tags/}"
if ! git branch -r --contains "$TAG_NAME" | grep -qE "origin/(main|develop)"; then
echo "Error: Tag $TAG_NAME is not on main or develop branch"
exit 1
fi
BRANCH=$(git branch -r --contains "$TAG_NAME" | grep -E "origin/(main|develop)" | head -1 | sed 's|origin/||' | tr -d ' ')
echo "Tag $TAG_NAME verified on $BRANCH branch"

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache: true

- name: Get version from tag
id: version
run: |
VERSION="${GITHUB_REF#refs/tags/}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Tag version: ${VERSION}"

- name: Build binary
run: |
GOOS=linux GOARCH=amd64 go build \
-ldflags="-s -w -X 'apatit/internal/version.Version=${{ steps.version.outputs.version }}'" \
-o apatit-linux-amd64 \
./cmd/apatit

- name: Create GitHub Release and Upload Binary
uses: softprops/action-gh-release@v1
with:
files: |
apatit-linux-amd64
locations.json
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-docker-image:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: [lint, build-binary]
if: startsWith(github.ref, 'refs/tags/v')

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Verify tag is on main or develop branch
run: |
TAG_NAME="${GITHUB_REF#refs/tags/}"
if ! git branch -r --contains "$TAG_NAME" | grep -qE "origin/(main|develop)"; then
echo "Error: Tag $TAG_NAME is not on main or develop branch"
exit 1
fi
BRANCH=$(git branch -r --contains "$TAG_NAME" | grep -E "origin/(main|develop)" | head -1 | sed 's|origin/||' | tr -d ' ')
echo "Tag $TAG_NAME verified on $BRANCH branch"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.meta.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
.vscode
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [v1.0.0] - 2025-12-03

### Added
- Prometheus metrics exporter for Ping-Admin monitoring service
- HTTP server with `/metrics` endpoint for Prometheus scraping
- JSON stats API endpoints (`/stats?type=task` and `/stats?type=all`)
- Support for multiple task monitoring with concurrent processing
- Automatic metrics collection with configurable refresh intervals
- Location name translation via `locations.json` file
- Automatic cleanup of stale metrics when monitoring points are removed
- Comprehensive Prometheus metrics:
- Exporter metrics (service info, refresh intervals, loops, errors)
- Monitoring point metrics (status, connection time, DNS lookup, server processing, total duration, speed, timestamps, staleness)
- Configuration via command-line flags and environment variables
- Docker image support with multi-stage build
- Graceful shutdown handling with signal support
- Request retry mechanism with configurable retry count
- Randomized request delays to prevent API throttling
- Rate limiting with configurable maximum requests per second (default: 2 requests/second)
- Staleness detection and reporting for monitoring points
- Support for English MP name translation
- Docker Compose configuration for easy deployment
- CI/CD workflow with linting and building
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM golang:1.24-alpine AS build
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG VERSION="v1.0.0"
RUN go build -v -ldflags="-s -w -X 'apatit/internal/version.Version=${VERSION}'" -o /app/apatit ./cmd/apatit

FROM alpine:3.21
ARG VERSION="latest"

RUN apk add --no-cache ca-certificates

LABEL org.opencontainers.image.title="APATIT (Advanced Ping-Admin Tasks Indicators Transducer)"
LABEL org.opencontainers.image.description="Transducer for Tasks Indicators from https://ping-admin.com/"
LABEL org.opencontainers.image.source="https://github.com/ostrovok-tech/apatit"
LABEL org.opencontainers.image.version="${VERSION}"

COPY --from=build /app/apatit /usr/local/bin/apatit
COPY locations.json /app/locations.json
WORKDIR /app

RUN addgroup -S appgroup && adduser -S appuser -G appgroup

USER appuser
EXPOSE 8080
ENV LISTEN_ADDRESS=:8080

ENTRYPOINT [ "apatit" ]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Ostrovok! Tech

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading