Skip to content

Commit

Permalink
Merge pull request #8 from arvancloud/improve
Browse files Browse the repository at this point in the history
Improve
  • Loading branch information
hatamiarash7 authored Mar 3, 2023
2 parents e6ba1e6 + ebab14f commit 29e7226
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 73 deletions.
51 changes: 0 additions & 51 deletions .github/workflows/dockerhub-publish.yml

This file was deleted.

74 changes: 74 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Release

on:
release:
types: [published]

jobs:
init:
name: 🚩 Initialize
runs-on: ubuntu-latest
steps:
- name: Cancel previous workflow
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

docker:
name: 🐳 Build Docker image
runs-on: ubuntu-20.04
needs: init
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get repository info
uses: gacts/github-slug@v1
id: slug

- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

- name: Login to Dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_LOGIN }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get Current Date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"

- name: Build & Push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7
build-args: |
APP_VERSION=${{ steps.slug.outputs.version }}"
DATE_CREATED=${{ steps.date.outputs.date }}
tags: |
r1cloud/cdn-exporter:${{ steps.slug.outputs.version }}
r1cloud/cdn-exporter:latest
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: r1cloud/cdn-exporter:latest
exit-code: "0"
ignore-unfixed: true
vuln-type: "os,library"
severity: "CRITICAL,HIGH"
format: "template"
template: "@/contrib/sarif.tpl"
output: "trivy-results.sarif"

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "trivy-results.sarif"
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ COPY ./package*.json ./
RUN npm install

FROM node:14-alpine AS APP

ARG APP_VERSION="undefined@docker"

LABEL \
org.opencontainers.image.title="cdn-exporter" \
org.opencontainers.image.description="Prometheus exporter for ArvanCloud CDN" \
org.opencontainers.image.url="https://github.com/arvancloud/ar-prometheus-exporter" \
org.opencontainers.image.source="https://github.com/arvancloud/ar-prometheus-exporter" \
org.opencontainers.image.vendor="arvancloud" \
org.opencontainers.image.author="arvancloud" \
org.opencontainers.version="$APP_VERSION" \
org.opencontainers.image.created="$DATE_CREATED" \
org.opencontainers.image.licenses="MIT"

WORKDIR /app
COPY . .
COPY --from=BUILDER /app/node_modules node_modules
Expand Down
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
# ar-prometheus-exporter
# CDN Prometheus exporter

![logo](.github/logo.svg)

A very simple Prometheus exporter that exposes metrics from ArvanCloud API as described in the [documentation](https://www.arvancloud.ir/api/cdn/4.0).
A very simple Prometheus exporter that exposes metrics from ArvanCloud CDN API as described in the [documentation](https://www.arvancloud.ir/api/cdn/4.0).

## How-to

You can run the exporter using Docker:

```bash
git clone [email protected]:arvancloud/ar-prometheus-exporter.git && cd ar-prometheus-exporter
docker build -t ar-prometheus-exporter .
docker run -d \
-p 9786:9786 \
-e DOMAINS=example.com,example.ir \
-e API_KEY=TOKEN_HERE \
ar-prometheus-exporter
r1cloud/cdn-exporter
```

### Metrics
Expand Down Expand Up @@ -46,8 +44,3 @@ The exporter exposes the following metrics, all returned per PoP:
| `BASE_URL` | Arvan base URL | string | <https://napi.arvancloud.ir/cdn/4.0> |
| `METRICS_PERIOD` | Arvan report period | enum(1h, 3h, 6h, 12h, 24h, 7d, 30d) | 3h |
| `METRICS_PREFIX` | exported metrics prefix | string | `arvancloud_cdn_` |

### 👨🏻‍💻 Contributors

- SadeghHayeri [![https://github.com/sadeghhayeri](https://img.shields.io/github/followers/sadeghhayeri?color=red&label=Follow&logo=github&style=flat-square)](https://github.com/sadeghhayeri)
- Yazdan [![https://github.com/yzdann](https://img.shields.io/github/followers/yzdann?color=red&label=Follow&logo=github&style=flat-square)](https://github.com/yzdann)
20 changes: 8 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
version: '3.2'
service:
ar-exporter:
build:
context: .
dockerfile: ./dockerfile
targer: app
container_name: ar-exporter
version: "3.9"

services:
cdn-exporter:
image: r1cloud/cdn-exporter
ports:
- 9786:9786
- 9786:9786
environment:
DOMAINS: example.com
API_KEY: arvan-api-key
network_mode: "bridge"
DOMAINS: example.com
API_KEY: arvan-api-key

0 comments on commit 29e7226

Please sign in to comment.