diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 764179a3..326c29ef 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -5,7 +5,9 @@ about: If you're having an issue or see an error --- ### Describe the bug -Try to explain what issue your'e having in detail. You can copy and paste the issue from the log file in your root directory `/logs/statup.log`. +Try to explain what issue your'e having in detail. You can copy and paste the issue from the log file in your root directory `/logs/statping.log`. + +You can set the environment variable `ALLOW_REPORTS` to `true` to allow errors to be sent to our error reporting server. ### To Reproduce Steps to reproduce the behavior: diff --git a/.github/ISSUE_TEMPLATE/issue-report.md b/.github/ISSUE_TEMPLATE/issue-report.md index 08980e76..7088ae19 100644 --- a/.github/ISSUE_TEMPLATE/issue-report.md +++ b/.github/ISSUE_TEMPLATE/issue-report.md @@ -7,6 +7,8 @@ about: If you're having an issue or see an error ### Describe the bug A clear and concise description of what the bug is. +You can set the environment variable `ALLOW_REPORTS` to `true` to allow errors to be sent to our error reporting server. + ### To Reproduce Steps to reproduce the behavior: 1. Go to '...' diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 519d640a..d4607ff5 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -160,8 +160,7 @@ jobs: - name: Postman Tests uses: matt-ball/newman-action@master with: - postmanApiKey: ${{ secrets.POSTMAN_API }} - collection: 1898229-94807b85-ef65-4370-9144-b1a74e04cb0e - environment: ./dev/postman_environment.json + collection: ./dev/postman.json + environment: ./dev/postman_environment_sqlite.json timeoutRequest: 15000 - delayRequest: 1000 + delayRequest: 500 diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index a04aea68..cdfb43d6 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -101,7 +101,7 @@ jobs: env: VERSION: ${{ env.VERSION }} run: | - make build + make build certs chmod +x statping mv statping $(go env GOPATH)/bin/ @@ -143,7 +143,7 @@ jobs: env: COVERALLS: ${{ secrets.COVERALLS }} - test-postman: + test-postman-sqlite: needs: compile runs-on: ubuntu-latest steps: @@ -175,17 +175,128 @@ jobs: - name: Run Statping run: | - API_SECRET=demosecret123 statping --port=8080 > /dev/null & + API_SECRET=demosecret123 statping --port=8585 > /dev/null & sleep 3 - - name: Postman Tests + - name: Postman SQLite Tests uses: matt-ball/newman-action@master with: - postmanApiKey: ${{ secrets.POSTMAN_API }} - collection: 1898229-94807b85-ef65-4370-9144-b1a74e04cb0e - environment: ./dev/postman_environment.json + apiKey: ${{ secrets.POSTMAN_API }} + collection: ./dev/postman.json + environment: ./dev/postman_env_sqlite.json timeoutRequest: 15000 - delayRequest: 1000 + delayRequest: 500 + + test-postman-mysql: + needs: compile + runs-on: ubuntu-latest + + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: password123 + MYSQL_DATABASE: statping + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '1.14.2' + + - name: Setting ENV's + run: | + echo "::add-path::$(go env GOPATH)/bin" + echo "::add-path::/opt/hostedtoolcache/node/10.20.1/x64/bin" + echo ::set-env name=VERSION::$(cat version.txt) + shell: bash + + - name: Download Compiled Frontend (rice-box.go) + uses: actions/download-artifact@v1 + with: + name: static-rice-box + path: ./source + + - name: Install Statping + env: + VERSION: ${{ env.VERSION }} + run: | + make build + chmod +x statping + mv statping $(go env GOPATH)/bin/ + + - name: Run Statping + run: | + API_SECRET=demosecret123 statping --port=8585 > /dev/null & + sleep 3 + + - name: Postman MySQL Tests + uses: matt-ball/newman-action@master + with: + apiKey: ${{ secrets.POSTMAN_API }} + collection: ./dev/postman.json + environment: ./dev/postman_env_mysql.json + timeoutRequest: 15000 + delayRequest: 500 + + test-postman-postgres: + needs: compile + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:10.8 + env: + POSTGRES_USER: root + POSTGRES_PASSWORD: password123 + POSTGRES_DB: statping + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '1.14.2' + + - name: Setting ENV's + run: | + echo "::add-path::$(go env GOPATH)/bin" + echo "::add-path::/opt/hostedtoolcache/node/10.20.1/x64/bin" + echo ::set-env name=VERSION::$(cat version.txt) + shell: bash + + - name: Download Compiled Frontend (rice-box.go) + uses: actions/download-artifact@v1 + with: + name: static-rice-box + path: ./source + + - name: Install Statping + env: + VERSION: ${{ env.VERSION }} + run: | + make build + chmod +x statping + mv statping $(go env GOPATH)/bin/ + + - name: Run Statping + run: | + API_SECRET=demosecret123 statping --port=8585 > /dev/null & + sleep 3 + + - name: Postman Postgres Tests + uses: matt-ball/newman-action@master + with: + apiKey: ${{ secrets.POSTMAN_API }} + collection: ./dev/postman.json + environment: ./dev/postman_env_postgres.json + timeoutRequest: 15000 + delayRequest: 500 build-binaries: needs: compile @@ -250,7 +361,7 @@ jobs: path: ./build upload-release: - needs: [test, test-postman, build-binaries] + needs: [test, test-postman-sqlite, test-postman-mysql, test-postman-postgres, build-binaries] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 04466ec9..b5ba5fda 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -8,11 +8,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Stale Issues - uses: actions/stale@v1.1.0 + uses: actions/stale@v3 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: "This issue hasn't had any updates in a while. If this is still a problem, please create a new issue." stale-issue-label: "stale" days-before-stale: 30 days-before-close: 7 - exempt-issue-labels: "bug,urgent,feature,pinned,locked" + exempt-issue-label: "bug,urgent,feature,pinned,locked" diff --git a/CHANGELOG.md b/CHANGELOG.md index d9e4476c..32471f02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,25 @@ +# 0.90.45 (06-01-2020) +- Merged PR [#612](https://github.com/statping/statping/pull/612) for edit/create service issue. + +# 0.90.44 (05-25-2020) +- Modified Makefile to include "netgo" tag during golang build + +# 0.90.43 (05-21-2020) +- Fixed service TLS checkbox form for edit and create +- Modified ICMP ping's to use system's "ping" command (doesn't need root access) + +# 0.90.42 (05-20-2020) +- Fixed TCP services that dont use TLS. + +# 0.90.41 (05-20-2020) +- Added TLS Client Cert/Key feature for HTTP and TCP/UDP services +- Replaced environment variable ADMIN_PASS to ADMIN_PASSWORD. + +# 0.90.40 (05-18-2020) +- Fixed issues with MySQL and Postgres taking forever to insert sample data (now run in bulk) +- Removed API Authentication for /api/logout route +- Modified Core Sample/Upstart row to include NAME, DESCRIPTION, and DOMAIN environment vars (also added default values) + # 0.90.39 (05-15-2020) - Modified some SCSS designs for services failures in group - Fixed Twilio notifier and tests diff --git a/Dockerfile b/Dockerfile index be485d89..a9846339 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,7 @@ COPY --from=base /usr/local/bin/sass /usr/local/bin/ COPY --from=base /usr/local/share/ca-certificates /usr/local/share/ WORKDIR /app +VOLUME /app ENV IS_DOCKER=true ENV SASS=/usr/local/bin/sass diff --git a/Makefile b/Makefile index 30b9ac1f..35debf81 100644 --- a/Makefile +++ b/Makefile @@ -162,13 +162,13 @@ build-win: go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-windows-386/statping.exe ./cmd build-darwin: - GO111MODULE="on" GOOS=darwin GOARCH=amd64 go build -a -ldflags "-s -w -X main.VERSION=${VERSION}" -o releases/statping-darwin-amd64/statping --tags "darwin" ./cmd + GO111MODULE="on" GOOS=darwin GOARCH=amd64 go build -a -ldflags "-s -w -X main.VERSION=${VERSION}" -o releases/statping-darwin-amd64/statping --tags "netgo darwin" ./cmd build-linux: CGO_ENABLED=1 GO111MODULE="on" GOOS=linux GOARCH=amd64 \ - go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-amd64/statping --tags "linux" ./cmd + go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-amd64/statping --tags "netgo linux" ./cmd CGO_ENABLED=1 GO111MODULE="on" GOOS=linux GOARCH=386 \ - go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-386/statping --tags "linux" ./cmd + go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-386/statping --tags "netgo linux" ./cmd build-linux-arm: CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc-6 CXX=arm-linux-gnueabihf-g++-6 GO111MODULE="on" GOOS=linux GOARCH=arm GOARM=7 \ @@ -322,5 +322,13 @@ postman: clean compile newman run -e dev/postman_environment.json dev/postman.json killall statping +certs: + openssl req -newkey rsa:2048 \ + -new -nodes -x509 \ + -days 3650 \ + -out cert.pem \ + -keyout key.pem \ + -subj "/C=US/ST=California/L=Santa Monica/O=Statping/OU=Development/CN=localhost" + .PHONY: all build build-all build-alpine test-all test test-api docker frontend up down print_details lite sentry-release snapcraft build-linux build-mac build-win build-all postman .SILENT: travis_s3_creds diff --git a/cmd/cli.go b/cmd/cli.go index ffbed998..083b55dd 100644 --- a/cmd/cli.go +++ b/cmd/cli.go @@ -285,7 +285,7 @@ func runOnce() error { func checkGithubUpdates() (githubResponse, error) { url := "https://api.github.com/repos/statping/statping/releases/latest" - contents, _, err := utils.HttpRequest(url, "GET", nil, nil, nil, time.Duration(2*time.Second), true) + contents, _, err := utils.HttpRequest(url, "GET", nil, nil, nil, time.Duration(2*time.Second), true, nil) if err != nil { return githubResponse{}, err } diff --git a/cmd/main.go b/cmd/main.go index 14f98f0a..bffac4d6 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -114,8 +114,9 @@ func start() { } if utils.Params.GetBool("SAMPLE_DATA") { + log.Infoln("Adding Sample Data") if err := configs.TriggerSamples(); err != nil { - exit(errors.Wrap(err, "error creating database")) + exit(errors.Wrap(err, "error adding sample data")) } } else { if err := core.Samples(); err != nil { diff --git a/database/database.go b/database/database.go index 479aa9ce..1ed39905 100644 --- a/database/database.go +++ b/database/database.go @@ -104,6 +104,23 @@ type Database interface { FormatTime(t time.Time) string ParseTime(t string) (time.Time, error) DbType() string + GormDB() *gorm.DB + ChunkSize() int +} + +func (it *Db) ChunkSize() int { + switch it.Database.Dialect().GetName() { + case "mysql": + return 3000 + case "postgres": + return 3000 + default: + return 100 + } +} + +func (it *Db) GormDB() *gorm.DB { + return it.Database } func (it *Db) DbType() string { diff --git a/dev/docker-compose.db.yml b/dev/docker-compose.db.yml index c76a1254..434f8e8f 100644 --- a/dev/docker-compose.db.yml +++ b/dev/docker-compose.db.yml @@ -10,7 +10,7 @@ services: POSTGRES_DB: statping POSTGRES_USER: root ports: - - "127.0.0.1:5432:5432" + - 5432:5432 healthcheck: test: ["CMD-SHELL", "pg_isready -U root"] interval: 15s @@ -27,7 +27,7 @@ services: MYSQL_USER: root MYSQL_PASSWORD: password123 ports: - - "127.0.0.1:3306:3306" + - 3306:3306 healthcheck: test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] timeout: 20s diff --git a/dev/docker-compose.full.yml b/dev/docker-compose.full.yml index b293b5ce..740c75b8 100644 --- a/dev/docker-compose.full.yml +++ b/dev/docker-compose.full.yml @@ -1,73 +1,48 @@ version: '2.3' + +############################################### +# Statping Full Stack +# +# Statping SQLIte => http://localhost:8080 +# Statping MySQL => http://localhost:8081 +# Statping Postgres => http://localhost:8082 +# Statping MariaDB => http://localhost:8083 +# +# Adminer => http://localhost:8282 +# Prometheus => http://localhost:7050 +# Grafana => http://localhost:3000 +# +# MySQL => http://localhost:3306 +# Postgres => http://localhost:5432 +# MariaDB => http://localhost:3307 +# +############################################### + services: - nginx-proxy: - image: jwilder/nginx-proxy - ports: - - 80:80 - volumes: - - /var/run/docker.sock:/tmp/docker.sock:ro - networks: - - statping - -# statping_dev: -# container_name: statping_dev -# build: -# context: . -# dockerfile: ./dev/Dockerfile.dev -# args: -# VERSION: DEV -# COMMIT: DEV -# restart: on-failure -# volumes: -# - ./:/go/src/github.com/statping/statping -# environment: -# VIRTUAL_HOST: local.statping.com -# VIRTUAL_PORT: 8888 -# GO_ENV: test -# DB_CONN: sqlite -# API_SECRET: exampleapisecret -# NAME: Statping on SQLite -# DOMAIN: http://localhost:4000 -# DESCRIPTION: This is a dev environment on SQLite! -# ADMIN_USER: admin -# ADMIN_PASS: admin -# PORT: 8585 -# SERVICES: '[{"name": "Local Statping", "type": "http", "domain": "http://localhost:8585", "interval": 30}]' -# ports: -# - 8888:8888 -# - 8585:8585 -# networks: -# - statping -# healthcheck: -# test: ["CMD-SHELL", "curl -f http://localhost:8585/health || false"] -# timeout: 2s -# interval: 20s -# retries: 30 - - statping: - container_name: statping + statping_sqlite: + container_name: statping_sqlite build: - context: ./ + context: ../ restart: on-failure volumes: - ./docker/statping/sqlite:/app + - ./services.yml:/app/services.yml environment: - SERVICES: '[{"name": "Local Statping", "type": "http", "domain": "http://localhost:8585", "interval": 30}]' - VIRTUAL_HOST: sqlite.dev.statping.com - VIRTUAL_PORT: 8080 DB_CONN: sqlite API_SECRET: exampleapisecret - NAME: Statping on SQLite - DOMAIN: http://localhost:4000 + NAME: Statping + DOMAIN: http://localhost:8080 DESCRIPTION: This is a dev environment on SQLite! ADMIN_USER: admin - ADMIN_PASS: admin + ADMIN_PASSWORD: admin + SAMPLE_DATA: 'false' ports: - - 4000:8080 + - 8080:8080 networks: - - statping + - database + - frontend healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"] timeout: 2s @@ -77,88 +52,124 @@ services: statping_mysql: container_name: statping_mysql build: - context: ./ + context: ../ restart: on-failure - ports: - - 4005:8080 volumes: - ./docker/statping/mysql:/app - links: - - mysql + - ./services.yml:/app/services.yml environment: - VIRTUAL_HOST: mysql.dev.statping.com - VIRTUAL_PORT: 8080 DB_CONN: mysql DB_HOST: mysql - DB_PORT: 3306 - DB_DATABASE: statping DB_USER: root DB_PASS: password123 + DB_DATABASE: statping + DB_PORT: 3306 API_SECRET: exampleapisecret - NAME: Statping on MySQL - DOMAIN: http://localhost:4005 + NAME: Statping MySQL + DOMAIN: http://localhost:8081 DESCRIPTION: This is a dev environment on MySQL! ADMIN_USER: admin - ADMIN_PASS: admin + ADMIN_PASSWORD: admin + SAMPLE_DATA: 'false' + ports: + - 8081:8080 networks: - - statping - depends_on: - mysql: - condition: service_healthy + - database + - frontend healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"] timeout: 2s interval: 10s retries: 20 + depends_on: + mysql: + condition: service_healthy statping_postgres: container_name: statping_postgres build: - context: ./ + context: ../ restart: on-failure - ports: - - 4010:8080 volumes: - - ./docker/statping/postgres:/app - links: - - postgres + - ./docker/statping/mysql:/app + - ./services.yml:/app/services.yml environment: - VIRTUAL_HOST: postgres.dev.statping.com - VIRTUAL_PORT: 8080 DB_CONN: postgres DB_HOST: postgres - DB_PORT: 5432 - DB_DATABASE: statping DB_USER: root DB_PASS: password123 + DB_DATABASE: statping + DB_PORT: 5432 API_SECRET: exampleapisecret - NAME: Statping on Postgres - DOMAIN: http://localhost:4010 + NAME: Statping Postgres + DOMAIN: http://localhost:8082 DESCRIPTION: This is a dev environment on Postgres! ADMIN_USER: admin - ADMIN_PASS: admin + ADMIN_PASSWORD: admin + SAMPLE_DATA: 'false' + ports: + - 8082:8080 networks: - - statping + - database + - frontend + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"] + timeout: 2s + interval: 10s + retries: 20 depends_on: postgres: condition: service_healthy + + statping_mariadb: + container_name: statping_mariadb + build: + context: ../ + restart: on-failure + volumes: + - ./docker/statping/mariadb:/app + - ./services.yml:/app/services.yml + environment: + DB_CONN: mysql + DB_HOST: mariadb + DB_USER: root + DB_PASS: password123 + DB_DATABASE: statping + DB_PORT: 3306 + API_SECRET: exampleapisecret + NAME: Statping MariaDB + DOMAIN: http://localhost:8083 + DESCRIPTION: This is a dev environment on MariaDB! + ADMIN_USER: admin + ADMIN_PASSWORD: admin + SAMPLE_DATA: 'false' + ports: + - 8083:8080 + networks: + - database + - frontend healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"] - timeout: 5s - interval: 5s - retries: 30 + timeout: 2s + interval: 10s + retries: 20 + depends_on: + mariadb: + condition: service_healthy postgres: container_name: postgres image: postgres volumes: - ./docker/databases/postgres:/var/lib/postgresql/data + ports: + - 5432:5432 environment: POSTGRES_PASSWORD: password123 POSTGRES_DB: statping POSTGRES_USER: root networks: - - statping + - database healthcheck: test: ["CMD-SHELL", "pg_isready -U root"] interval: 15s @@ -175,95 +186,59 @@ services: MYSQL_ROOT_PASSWORD: password123 MYSQL_DATABASE: statping MYSQL_USER: root - MYSQL_PASSWORD: password + MYSQL_PASSWORD: password123 + ports: + - 3306:3306 networks: - - statping + - database healthcheck: test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] timeout: 20s interval: 15s retries: 30 - phpmyadmin: - container_name: phpmyadmin - image: phpmyadmin/phpmyadmin - restart: on-failure - depends_on: - mysql: - condition: service_healthy - ports: - - 5050:80 - links: - - mysql:db - environment: - VIRTUAL_HOST: phpmyadmin.statping.com - VIRTUAL_PORT: 80 - MYSQL_ROOT_PASSWORD: password123 - PMA_HOST: mysql - PMA_USER: root - PMA_PASSWORD: password123 - PMA_PORT: 3306 - networks: - - statping - - sqlite-web: - container_name: sqlite-web - image: coleifer/sqlite-web - restart: on-failure - command: sqlite_web -H 0.0.0.0 -r -x /data/statping.db - depends_on: - statping: - condition: service_healthy - ports: - - 6050:8080 - links: - - statping + mariadb: + container_name: mariadb + image: mariadb volumes: - - ./docker/statping/sqlite/statping.db:/data/statping.db:ro + - ./docker/databases/mariadb:/var/lib/mysql + restart: always environment: - VIRTUAL_HOST: sqladmin.statping.com - VIRTUAL_PORT: 8080 - SQLITE_DATABASE: /data/statping.db - networks: - - statping - - pgadmin4: - container_name: pgadmin4 - image: fenglc/pgadmin4 - restart: on-failure - environment: - VIRTUAL_HOST: pgadmin.statping.com - VIRTUAL_PORT: 5050 - DEFAULT_USER: admin@admin.com - DEFAULT_PASSWORD: admin - depends_on: - postgres: - condition: service_healthy + MYSQL_ROOT_PASSWORD: password123 + MYSQL_DATABASE: statping + MYSQL_USER: root + MYSQL_PASSWORD: password123 ports: - - 7000:5050 - links: - - postgres:postgres + - 3307:3306 networks: - - statping + - database + healthcheck: + test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] + timeout: 20s + interval: 15s + retries: 30 + + adminer: + container_name: adminer + image: adminer + restart: always + networks: + - database + - frontend + ports: + - 8282:8080 prometheus: container_name: prometheus image: prom/prometheus:v2.0.0 restart: on-failure volumes: - - ./dev/prometheus.yml:/etc/prometheus/prometheus.yml + - ./prometheus.yml:/etc/prometheus/prometheus.yml - ./docker/databases/prometheus:/prometheus - links: - - statping - - statping_mysql - - statping_postgres ports: - 7050:9090 networks: - - statping - environment: - VIRTUAL_HOST: prometheus.statping.com - VIRTUAL_PORT: 9090 + - database healthcheck: test: "/bin/wget -q -Y off http://localhost:9090/status -O /dev/null > /dev/null 2>&1" interval: 10s @@ -277,25 +252,23 @@ services: - 3000:3000 volumes: - ./docker/grafana:/var/lib/grafana - - ./dev/grafana/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml - - ./dev/grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/dashboard.yml - - ./dev/grafana/statping_dashboard.json:/etc/grafana/provisioning/dashboards/statping_dashboard.json + - ./grafana/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml + - ./grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/dashboard.yml + - ./grafana/statping_dashboard.json:/etc/grafana/provisioning/dashboards/statping_dashboard.json environment: - - VIRTUAL_HOST=grafana.statping.com - - VIRTUAL_PORT=3000 - GF_USERS_ALLOW_SIGN_UP=false - GF_AUTH_ANONYMOUS_ENABLED=true depends_on: prometheus: condition: service_healthy - links: - - prometheus networks: - - statping + - frontend + - database healthcheck: test: "/usr/bin/wget -q -Y off http://localhost:3000/api/health -O /dev/null > /dev/null 2>&1" interval: 10s retries: 20 networks: - statping: + frontend: + database: diff --git a/dev/docker-compose.lite.yml b/dev/docker-compose.lite.yml index 65c47a68..75e48a54 100644 --- a/dev/docker-compose.lite.yml +++ b/dev/docker-compose.lite.yml @@ -24,7 +24,7 @@ services: DOMAIN: http://localhost:8585 DESCRIPTION: This is a dev environment with auto reloading! ADMIN_USER: admin - ADMIN_PASS: admin + ADMIN_PASSWORD: admin PORT: 8585 ports: - 8888:8888 diff --git a/dev/grafana/grafana.ini b/dev/grafana/grafana.ini index 6fe59c41..6096b4a9 100644 --- a/dev/grafana/grafana.ini +++ b/dev/grafana/grafana.ini @@ -1,7 +1,10 @@ [users] # disable user signup / registration allow_sign_up = false +viewers_can_edit = true +editors_can_admin = true [auth.anonymous] # enable anonymous access enabled = true + diff --git a/dev/grafana/statping_dashboard.json b/dev/grafana/statping_dashboard.json index 6f354f85..b70dbf83 100644 --- a/dev/grafana/statping_dashboard.json +++ b/dev/grafana/statping_dashboard.json @@ -558,24 +558,14 @@ "templating": { "list": [ { - "allValue": null, - "current": {}, - "datasource": "${DS_PROMETHEUS}", "hide": 0, - "includeAll": false, - "label": "service", - "multi": false, - "name": "service", + "label": "datasource", + "name": "DS_PROMETHEUS", "options": [], - "query": "label_values(statup_service_latency, name)", + "query": "prometheus", "refresh": 1, "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false + "type": "datasource" } ] }, diff --git a/dev/postman.json b/dev/postman.json index 1aa1cb71..eb07a2ad 100644 --- a/dev/postman.json +++ b/dev/postman.json @@ -1,8 +1,8 @@ { "info": { - "_postman_id": "94807b85-ef65-4370-9144-b1a74e04cb0e", + "_postman_id": "3c6a7841-0b39-4878-a3a6-1c76832b7679", "name": "Statping", - "description": "The Statping API allows you to programmatically access data on your Statping server.\n\nThe easiest way to get started with the API is by running your own Docker or local instance of the Statping server.\n\n\n\n# Authentication\n\nAn API Key is required to be sent as part of every request to the Statping API, by using the `Authorization` and the API Secret Key as a header.\n\n> If you do not have an API Secret Key, you can find it on the Settings page.\n\nYou can Authenticate by implementing the following...\n- Using the `Authorization` header with API Secret Key\n- Setting `GO_ENV` to `test` to bypass all authentication\n- Adding `?api=` URL Query along with the API Secret Key\n- Being logged into Statping as an admin (using JWT sessions/cookies)\n\n# Environment Variables\nStatping includes many environment variables that can give you more control over your instance. Please view the [Environment Variables Wiki](https://github.com/statping/statping/wiki/Environment-Variables) page to view a complete list. Below are a couple important ones...\n- `STATPING_DIR` - Statping's working directory. By default, this will be set to the current working directory. This path will contain the `config.yml` file, `logs`, and `assets` folder. \n- `SASS` - Absolute path to the `sass` executable. By default it will attempt to find `sass` in your `$PATH`. \n\n# Demo\nYou can checkout the Statping Demo instance at [https://demo.statping.com](https://demo.statping.com). All features are available for you to experiment with. The API Secret Key is `demoapisecret123`. Since this instance is public, it will be reset with sample data **every 90 minutes**.\n", + "description": "The Statping API allows you to programmatically access data on your Statping server.\n\nThe easiest way to get started with the API is by running your own Docker or local instance of the Statping server.\n\n\n\n# Authentication\n\nAn API Key is required to be sent as part of every request to the Statping API, by using the `Authorization` and the API Secret Key as a header.\n\n> If you do not have an API Secret Key, you can find it on the Settings page.\n\nYou can Authenticate by implementing the following...\n- Using the `Authorization` header with API Secret Key\n- Setting `GO_ENV` to `test` to bypass all authentication\n- Adding `?api=` URL Query along with the API Secret Key\n- Being logged into Statping as an admin (using JWT sessions/cookies)\n\n> Authentication will create a cookie named `statping_auth`.\n\n# Environment Variables\nStatping includes many environment variables that can give you more control over your instance. Please view the [Environment Variables Wiki](https://github.com/statping/statping/wiki/Environment-Variables) page to view a complete list. Below are a couple important ones...\n- `STATPING_DIR` - Statping's working directory. By default, this will be set to the current working directory. This path will contain the `config.yml` file, `logs`, and `assets` folder. \n- `SASS` - Absolute path to the `sass` executable. By default it will attempt to find `sass` in your `$PATH`. \n\n# Demo\nYou can checkout the Statping Demo instance at [https://demo.statping.com](https://demo.statping.com). All features are available for you to experiment with. The API Secret Key is `demoapisecret123`. Since this instance is public, it will be reset with sample data **every 90 minutes**.\n", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ @@ -15,35 +15,40 @@ { "listen": "test", "script": { - "id": "08b8f487-2318-44b9-bdb8-f1f1041e9462", + "id": "29b5dc8d-60c1-4f70-853d-49114af6b254", "exec": [ - "var tm = Math.round(new Date().getTime()/1000);", - "pm.globals.set(\"start_time\", tm-259200);", + "var tm = Math.round(new Date().getTime() / 1000);", + "pm.globals.set(\"start_time\", tm - 259200);", "pm.globals.set(\"end_time\", tm);", "", + "var connection = pm.environment.get(\"db_connection\");", + "", "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", "});", "", - "pm.test(\"Check Core API Route\", function () {", + "pm.test(\"Check Setup\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.config.connection).to.eql(\"sqlite3\");", + " pm.expect(jsonData.message).to.eql(\"success\");", "});" ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "id": "e5e9ea08-21d1-48d6-b019-9b4f93e813e5", + "exec": [ + "" + ], + "type": "text/javascript" + } } ], "request": { "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{api_key}}", - "type": "string" - } - ] + "type": "noauth" }, "method": "POST", "header": [ @@ -59,32 +64,32 @@ "urlencoded": [ { "key": "db_host", - "value": "localhost", + "value": "{{db_host}}", "type": "text" }, { "key": "db_user", - "value": "root", + "value": "{{db_user}}", "type": "text" }, { "key": "db_password", - "value": "password123", + "value": "{{db_password}}", "type": "text" }, { "key": "db_database", - "value": "statping", + "value": "{{db_database}}", "type": "text" }, { "key": "db_connection", - "value": "sqlite", + "value": "{{db_connection}}", "type": "text" }, { "key": "db_port", - "value": "3306", + "value": "{{db_port}}", "type": "text" }, { @@ -147,7 +152,7 @@ { "listen": "prerequest", "script": { - "id": "3faca200-30d4-4daf-8edf-059bf6b6fbf0", + "id": "ee74f82f-761a-46ae-a183-044b3d17c416", "type": "text/javascript", "exec": [ "" @@ -157,7 +162,7 @@ { "listen": "test", "script": { - "id": "a72027a1-280f-4ebf-887d-a19e9866d0ab", + "id": "99e1ad44-98bc-431c-bec6-d5b4ea3b94ac", "type": "text/javascript", "exec": [ "" @@ -176,7 +181,7 @@ { "listen": "test", "script": { - "id": "08b8f487-2318-44b9-bdb8-f1f1041e9462", + "id": "fb5b5fcf-86a0-4d22-9f4c-cc6955eb414a", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -186,7 +191,6 @@ " var jsonData = pm.response.json();", " pm.expect(jsonData.name).to.eql(\"Statping Monitoring Sample Data\");", " pm.expect(jsonData.using_cdn).to.eql(false);", - " pm.expect(jsonData.admin).to.eql(false);", "});" ], "type": "text/javascript" @@ -255,13 +259,171 @@ } ] }, + { + "name": "Logs", + "event": [ + { + "listen": "test", + "script": { + "id": "a694b786-796e-4d54-87fc-1848525bba65", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api/logs", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "logs" + ] + }, + "description": "This endpoint will return a list of the last 1,000 logs." + }, + "response": [ + { + "name": "Statping Details", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Length", + "value": "398" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Sat, 02 May 2020 01:06:09 GMT" + } + ], + "cookie": [], + "body": "{\n \"admin\": false,\n \"allow_reports\": false,\n \"created_at\": \"2020-05-02T01:00:07.885973685Z\",\n \"description\": \"This data is only used to testing\",\n \"domain\": \"http://localhost:8080\",\n \"footer\": null,\n \"logged_in\": false,\n \"migration_id\": 1588381207,\n \"name\": \"Statping Sample Data\",\n \"setup\": true,\n \"started_on\": \"2020-05-02T01:00:14.255837864Z\",\n \"updated_at\": \"2020-05-02T01:00:12.731269305Z\",\n \"using_cdn\": false,\n \"version\": \"0.90.34\"\n}" + } + ] + }, + { + "name": "Logs Last Line", + "event": [ + { + "listen": "test", + "script": { + "id": "21501cae-bea0-4b6a-87cc-32a7f6da0771", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api/logs", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "logs" + ] + }, + "description": "This endpoint will return the last line in the logs." + }, + "response": [ + { + "name": "Statping Details", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Length", + "value": "398" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Sat, 02 May 2020 01:06:09 GMT" + } + ], + "cookie": [], + "body": "{\n \"admin\": false,\n \"allow_reports\": false,\n \"created_at\": \"2020-05-02T01:00:07.885973685Z\",\n \"description\": \"This data is only used to testing\",\n \"domain\": \"http://localhost:8080\",\n \"footer\": null,\n \"logged_in\": false,\n \"migration_id\": 1588381207,\n \"name\": \"Statping Sample Data\",\n \"setup\": true,\n \"started_on\": \"2020-05-02T01:00:14.255837864Z\",\n \"updated_at\": \"2020-05-02T01:00:12.731269305Z\",\n \"using_cdn\": false,\n \"version\": \"0.90.34\"\n}" + } + ] + }, { "name": "Health Check", "event": [ { "listen": "test", "script": { - "id": "987cc831-4a88-45ea-a9d5-494d86887fc6", + "id": "1259b7bb-a330-4716-ae7c-386f96224a14", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -338,7 +500,7 @@ { "listen": "test", "script": { - "id": "2f977982-ef22-4cee-9c38-89ad4777d3e0", + "id": "04a41c9d-0659-44f8-9efb-d04fff1af6e3", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -406,7 +568,7 @@ { "listen": "test", "script": { - "id": "08b8f487-2318-44b9-bdb8-f1f1041e9462", + "id": "dbabc164-5030-441d-90f7-b29c7fe794df", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -486,7 +648,7 @@ { "listen": "test", "script": { - "id": "08b8f487-2318-44b9-bdb8-f1f1041e9462", + "id": "992ce59d-3cce-43f1-9c3d-895c55a3e0a1", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -566,7 +728,7 @@ { "listen": "test", "script": { - "id": "9b94f2ee-0918-4bc0-84a2-3b148b76126b", + "id": "8ee8bf21-4243-4f15-8a03-2189224360c7", "exec": [ "" ], @@ -636,7 +798,7 @@ { "listen": "prerequest", "script": { - "id": "883519e8-7c7d-49c0-9812-d988d0179907", + "id": "00ffb460-8bfc-4221-af12-b155a34c11fc", "type": "text/javascript", "exec": [ "" @@ -646,14 +808,15 @@ { "listen": "test", "script": { - "id": "7a0738e6-2fc4-45cb-9f1a-1cd57fb76b66", + "id": "ffe44bf8-4bf3-4175-bb4b-3c3910c674c3", "type": "text/javascript", "exec": [ "" ] } } - ] + ], + "protocolProfileBehavior": {} }, { "name": "Services", @@ -664,7 +827,7 @@ { "listen": "test", "script": { - "id": "d87f8a4e-7640-45b8-9d45-4f6e6f2463ee", + "id": "e89a245a-8ee6-4f3b-8cbc-5d7c3bbf687a", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -749,7 +912,7 @@ { "listen": "test", "script": { - "id": "023c5643-6cb1-4cd0-b775-566f232d68f8", + "id": "7c3e8784-0494-4957-ac45-b09c26580b40", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -850,7 +1013,7 @@ { "listen": "test", "script": { - "id": "023c5643-6cb1-4cd0-b775-566f232d68f8", + "id": "860fa275-aed7-481d-967f-11b481df49e0", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -986,7 +1149,7 @@ { "listen": "test", "script": { - "id": "023c5643-6cb1-4cd0-b775-566f232d68f8", + "id": "d89562d5-6742-447a-ae95-1ad044123f70", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1122,7 +1285,7 @@ { "listen": "test", "script": { - "id": "023c5643-6cb1-4cd0-b775-566f232d68f8", + "id": "e5af74ef-3ae5-45ef-ac0c-30ec1ed006c3", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1258,7 +1421,7 @@ { "listen": "test", "script": { - "id": "023c5643-6cb1-4cd0-b775-566f232d68f8", + "id": "b21c7e93-24a7-4c0a-90fa-89d3e34f0029", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1322,7 +1485,7 @@ { "listen": "test", "script": { - "id": "023c5643-6cb1-4cd0-b775-566f232d68f8", + "id": "c6f024c5-f81d-4aca-92e8-b93bf9ac9068", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1391,7 +1554,7 @@ { "listen": "test", "script": { - "id": "b5a67a19-fd08-40b0-a961-3e9474ab78c6", + "id": "cf487420-5c74-4572-b512-29fe6de72761", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1494,7 +1657,7 @@ { "listen": "test", "script": { - "id": "d4eb16fe-8495-40e5-9ca3-be20951e5133", + "id": "7f96b2ec-11e5-44ab-b353-c2b4fa034f80", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1602,7 +1765,7 @@ { "listen": "test", "script": { - "id": "b5a67a19-fd08-40b0-a961-3e9474ab78c6", + "id": "8f497902-ca10-45cb-bb98-96db1604b276", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1714,7 +1877,7 @@ { "listen": "test", "script": { - "id": "dd4d721d-d874-448b-abc9-59c1afceb58e", + "id": "ea18e56c-382d-42c4-9bc7-477da1d760fe", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1763,7 +1926,7 @@ { "listen": "test", "script": { - "id": "dd4d721d-d874-448b-abc9-59c1afceb58e", + "id": "c8b61f71-2f28-42a5-9ca1-e80038767fbe", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1795,7 +1958,10 @@ "header": [], "body": { "mode": "raw", - "raw": "" + "raw": "", + "options": { + "raw": {} + } }, "url": { "raw": "{{endpoint}}/api/services/{{service_id}}", @@ -1870,7 +2036,7 @@ { "listen": "prerequest", "script": { - "id": "4cd2ab82-e60d-45cd-9b74-cb4b5d893f4d", + "id": "2d965d82-4d9e-4c37-a3d2-286c75ae00de", "type": "text/javascript", "exec": [ "" @@ -1880,14 +2046,670 @@ { "listen": "test", "script": { - "id": "c7cb2b6d-289a-4073-b291-202bbec8cb44", + "id": "f3cd55c0-923e-43fa-ab6b-e26df9f20e0a", "type": "text/javascript", "exec": [ "" ] } } - ] + ], + "protocolProfileBehavior": {} + }, + { + "name": "Incidents", + "item": [ + { + "name": "View Service Incidents", + "event": [ + { + "listen": "test", + "script": { + "id": "575ede33-53ac-4e8b-9dbf-3560409b6d1f", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{endpoint}}/api/services/1/incidents", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "services", + "1", + "incidents" + ] + }, + "description": "View all incidents for a single service." + }, + "response": [ + { + "name": "View Service Incidents", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{endpoint}}/api/services/1/incidents", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "services", + "1", + "incidents" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Mon, 04 May 2020 03:13:44 GMT" + }, + { + "key": "Content-Length", + "value": "136" + }, + { + "key": "Connection", + "value": "close" + } + ], + "cookie": [], + "body": "[\n {\n \"id\": 1,\n \"title\": \"Service Downtime\",\n \"service\": 1,\n \"created_at\": \"2020-05-04T03:11:51.752374Z\",\n \"updated_at\": \"2020-05-04T03:11:51.752374Z\"\n }\n]" + } + ] + }, + { + "name": "Create Incident", + "event": [ + { + "listen": "test", + "script": { + "id": "6252ebad-26a9-481d-a233-e097306fc598", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Incidents JSON\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.status).to.eql(\"success\");", + " pm.expect(jsonData.method).to.eql(\"create\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"title\": \"Service Downtime\",\n\t\"description\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{endpoint}}/api/services/1/incidents", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "services", + "1", + "incidents" + ] + }, + "description": "Create an incident for a service." + }, + "response": [ + { + "name": "Create Incident", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"title\": \"Service Downtime\",\n\t\"description\": \"\",\n\t\"service\": 1\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{endpoint}}/api/services/1/incidents", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "services", + "1", + "incidents" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Mon, 04 May 2020 03:11:51 GMT" + }, + { + "key": "Content-Length", + "value": "207" + }, + { + "key": "Connection", + "value": "close" + } + ], + "cookie": [], + "body": "{\n \"status\": \"success\",\n \"type\": \"incident\",\n \"method\": \"create\",\n \"id\": 1,\n \"output\": {\n \"id\": 1,\n \"title\": \"Service Downtime\",\n \"service\": 1,\n \"created_at\": \"2020-05-04T03:11:51.752374Z\",\n \"updated_at\": \"2020-05-04T03:11:51.752374Z\"\n }\n}" + } + ] + }, + { + "name": "Update Service Incident", + "event": [ + { + "listen": "test", + "script": { + "id": "42cd68de-5bd4-4d4e-b687-fa0bafc1d61a", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"title\": \"Updated Downtime\",\n\t\"description\": \"This is an update for an incident\"\n}" + }, + "url": { + "raw": "{{endpoint}}/api/incidents/1", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "1" + ] + }, + "description": "View all incidents for a single service." + }, + "response": [] + }, + { + "name": "Delete Incident", + "event": [ + { + "listen": "test", + "script": { + "id": "c6735dbe-86e8-4b42-9b04-6fc1fea949df", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{endpoint}}/api/incidents/1", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "1" + ] + }, + "description": "View all incidents for a single service." + }, + "response": [ + { + "name": "Delete Incident", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{endpoint}}/api/incidents/2", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "2" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Mon, 04 May 2020 03:31:48 GMT" + }, + { + "key": "Content-Length", + "value": "207" + }, + { + "key": "Connection", + "value": "close" + } + ], + "cookie": [], + "body": "{\n \"status\": \"success\",\n \"type\": \"incident\",\n \"method\": \"delete\",\n \"id\": 2,\n \"output\": {\n \"id\": 2,\n \"title\": \"Service Downtime\",\n \"service\": 1,\n \"created_at\": \"2020-05-04T03:18:24.818629Z\",\n \"updated_at\": \"2020-05-04T03:18:24.818629Z\"\n }\n}" + } + ] + }, + { + "name": "Incident Updates", + "event": [ + { + "listen": "test", + "script": { + "id": "e2e7d38f-efae-44d1-9361-cd301547feb3", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{endpoint}}/api/incidents/2/updates", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "2", + "updates" + ] + }, + "description": "View all incidents for a single service." + }, + "response": [] + }, + { + "name": "Create Incident Update", + "event": [ + { + "listen": "test", + "script": { + "id": "4478e35f-8da6-4f74-9100-0bb92ac6466e", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"message\": \"Website is loading very slowly, looking into this.\",\n\t\"type\": \"Investigating\"\n}" + }, + "url": { + "raw": "{{endpoint}}/api/incidents/2/updates", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "2", + "updates" + ] + }, + "description": "View all incidents for a single service." + }, + "response": [ + { + "name": "Create Incident Update", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"message\": \"Website is loading very slowly, looking into this.\",\n\t\"type\": \"Investigating\"\n}" + }, + "url": { + "raw": "{{endpoint}}/api/incidents/2/updates", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "2", + "updates" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Mon, 04 May 2020 03:20:05 GMT" + }, + { + "key": "Content-Length", + "value": "261" + }, + { + "key": "Connection", + "value": "close" + } + ], + "cookie": [], + "body": "{\n \"status\": \"success\",\n \"type\": \"incident_update\",\n \"method\": \"create\",\n \"id\": 1,\n \"output\": {\n \"id\": 1,\n \"message\": \"Website is loading very slowly, looking into this.\",\n \"type\": \"Investigating\",\n \"created_at\": \"2020-05-04T03:20:05.102435Z\",\n \"updated_at\": \"2020-05-04T03:20:05.102435Z\"\n }\n}" + } + ] + }, + { + "name": "Delete Incident Update", + "event": [ + { + "listen": "test", + "script": { + "id": "4578b229-5a85-4d3c-acdc-360ad50a35f2", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{endpoint}}/api/incidents/2/updates/1", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "2", + "updates", + "1" + ] + }, + "description": "View all incidents for a single service." + }, + "response": [ + { + "name": "Delete Incident Update", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{endpoint}}/api/incidents/2/updates/1", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "2", + "updates", + "1" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Mon, 04 May 2020 03:23:00 GMT" + }, + { + "key": "Content-Length", + "value": "261" + }, + { + "key": "Connection", + "value": "close" + } + ], + "cookie": [], + "body": "{\n \"status\": \"success\",\n \"type\": \"incident_update\",\n \"method\": \"delete\",\n \"id\": 1,\n \"output\": {\n \"id\": 1,\n \"message\": \"Website is loading very slowly, looking into this.\",\n \"type\": \"Investigating\",\n \"created_at\": \"2020-05-04T03:20:05.102435Z\",\n \"updated_at\": \"2020-05-04T03:20:05.102435Z\"\n }\n}" + } + ] + } + ], + "protocolProfileBehavior": {} }, { "name": "Groups", @@ -1898,7 +2720,7 @@ { "listen": "test", "script": { - "id": "d87f8a4e-7640-45b8-9d45-4f6e6f2463ee", + "id": "e83ac60d-3683-441e-a78b-d15b6c2b704d", "exec": [ "pm.test(\"View All Groups\", function () {", " var jsonData = pm.response.json();", @@ -1979,7 +2801,7 @@ { "listen": "test", "script": { - "id": "023c5643-6cb1-4cd0-b775-566f232d68f8", + "id": "d2bba501-9674-4143-a51d-33721eb4785f", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2080,7 +2902,7 @@ { "listen": "test", "script": { - "id": "d4eb16fe-8495-40e5-9ca3-be20951e5133", + "id": "6ea60d3a-b601-41a8-8b5e-734f3946d34c", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2184,7 +3006,7 @@ { "listen": "test", "script": { - "id": "b5a67a19-fd08-40b0-a961-3e9474ab78c6", + "id": "4efd65bf-6e56-4600-91af-36cb82ffb125", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2214,7 +3036,10 @@ ], "body": { "mode": "raw", - "raw": "[{\"group\":1,\"order\":1},{\"group\":2,\"order\":2}]" + "raw": "[{\"group\":1,\"order\":1},{\"group\":2,\"order\":2}]", + "options": { + "raw": {} + } }, "url": { "raw": "{{endpoint}}/api/reorder/groups", @@ -2237,7 +3062,7 @@ { "listen": "test", "script": { - "id": "dd4d721d-d874-448b-abc9-59c1afceb58e", + "id": "ec903995-c37b-436a-b554-c9e4ee5ff52a", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2344,7 +3169,7 @@ { "listen": "prerequest", "script": { - "id": "4cd2ab82-e60d-45cd-9b74-cb4b5d893f4d", + "id": "abe8dbf2-9e63-49b5-b5d3-7a50217c87a3", "type": "text/javascript", "exec": [ "" @@ -2354,7 +3179,7 @@ { "listen": "test", "script": { - "id": "c7cb2b6d-289a-4073-b291-202bbec8cb44", + "id": "de397a38-c190-4928-92f0-393ab85e5342", "type": "text/javascript", "exec": [ "" @@ -2373,7 +3198,7 @@ { "listen": "test", "script": { - "id": "08b8f487-2318-44b9-bdb8-f1f1041e9462", + "id": "eaec5a14-dd31-4e9c-9e30-8999591514c3", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2505,7 +3330,7 @@ { "listen": "test", "script": { - "id": "f6848835-443c-4dfa-abb9-ddea712cd0d1", + "id": "f858d94a-6534-452b-9197-99c64d7b4009", "exec": [ "" ], @@ -2549,7 +3374,7 @@ { "listen": "test", "script": { - "id": "9a2977fe-9689-4039-bdcb-eaa34abee958", + "id": "20b79651-9175-4a30-98f3-4666ebf9ab05", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2638,7 +3463,7 @@ { "listen": "test", "script": { - "id": "1913466d-83b2-4d5b-ac48-89c9abdd0c8d", + "id": "fd7e8b36-70c2-4060-bb50-5d87e663dea3", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2744,7 +3569,7 @@ { "listen": "test", "script": { - "id": "555b7ba4-bb36-4e86-a541-fa5a5008f951", + "id": "925d3cea-fa59-42db-9d4e-154021cfbd37", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2834,7 +3659,7 @@ { "listen": "prerequest", "script": { - "id": "d23b1822-d1de-4545-9a82-3cf4719a7e82", + "id": "2802ca86-12c2-41ce-947d-e086fcb7c753", "exec": [ "" ], @@ -2844,7 +3669,7 @@ { "listen": "test", "script": { - "id": "b0d22bbd-a428-4df3-8295-b40542bfa21f", + "id": "19f750c7-1df2-4a03-b0f0-b487d80d4917", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2949,7 +3774,7 @@ { "listen": "test", "script": { - "id": "bd8c3425-a97f-4f8c-b849-71b65dd543ee", + "id": "d94974c7-7c6f-4298-8ab7-6bd7a789020f", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3050,7 +3875,7 @@ { "listen": "prerequest", "script": { - "id": "9720db1a-bc4c-4e05-94ea-2782aaafb793", + "id": "8cef4ad5-1c96-46e8-8fc9-9e9e044730dc", "type": "text/javascript", "exec": [ "" @@ -3060,7 +3885,7 @@ { "listen": "test", "script": { - "id": "c667ae2d-41f3-4dea-ab62-3b544e2bc8f9", + "id": "872da99f-a57d-4a54-bd5e-18b5529c715f", "type": "text/javascript", "exec": [ "" @@ -3079,7 +3904,7 @@ { "listen": "test", "script": { - "id": "e9105618-6db8-4a57-ae7f-782989842f4a", + "id": "9f3e4a3e-a690-4dcb-897f-fdfa8503d79f", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3164,7 +3989,7 @@ { "listen": "test", "script": { - "id": "acac30b6-3caa-46c9-89be-1efbadf89f22", + "id": "7a42a113-8bdb-47dd-a914-36bc2aa65aba", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3252,7 +4077,7 @@ { "listen": "test", "script": { - "id": "d714d71d-4d6a-4b2e-a6ea-16c34dec3041", + "id": "2a8a1a62-57ea-4a7a-9f0a-713ac548c151", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3291,7 +4116,10 @@ ], "body": { "mode": "raw", - "raw": "{\n \"method\": \"slack\",\n \"host\": \"https://hooks.slack.com/services/EXAMPLEIDHERE/BV33WKP0C/MtKw3Kc8BFylTv4pohKqHtXX\",\n \"enabled\": true,\n \"limits\": 55\n}" + "raw": "{\n \"method\": \"slack\",\n \"host\": \"https://hooks.slack.com/services/EXAMPLEIDHERE/BV33WKP0C/MtKw3Kc8BFylTv4pohKqHtXX\",\n \"enabled\": true,\n \"limits\": 55\n}", + "options": { + "raw": {} + } }, "url": { "raw": "{{endpoint}}/api/notifier/slack", @@ -3356,6 +4184,127 @@ "body": "{\n \"status\": \"success\",\n \"type\": \"string\",\n \"method\": \"update\",\n \"output\": \"slack\"\n}" } ] + }, + { + "name": "Test Notifier", + "event": [ + { + "listen": "test", + "script": { + "id": "198374af-ccbc-4e2e-8af2-df58622379d4", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Test Notifier\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.success).to.eql(false);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"method\": \"slack\",\n \"host\": \"https://hooks.slack.com/services/EXAMPLEIDHERE/BV33WKP0C/MtKw3Kc8BFylTv4pohKqHtXX\",\n \"enabled\": true,\n \"limits\": 55\n}", + "options": { + "raw": {} + } + }, + "url": { + "raw": "{{endpoint}}/api/notifier/slack/test", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "notifier", + "slack", + "test" + ] + }, + "description": "Update a notifier to change it's values." + }, + "response": [ + { + "name": "Test Notifier", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"method\": \"slack\",\n \"host\": \"https://hooks.slack.com/services/EXAMPLEIDHERE/BV33WKP0C/MtKw3Kc8BFylTv4pohKqHtXX\",\n \"enabled\": true,\n \"limits\": 55\n}", + "options": { + "raw": {} + } + }, + "url": { + "raw": "{{endpoint}}/api/notifier/slack/test", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "notifier", + "slack", + "test" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Mon, 04 May 2020 03:25:07 GMT" + }, + { + "key": "Connection", + "value": "close" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"success\": false,\n \"response\": \"There's been a glitch… | Slack

There’s been a glitch…

We’re not quite sure what went wrong. You can go back, or try looking on our Help Center if you need a hand.

\\n\\n\\n\\n\",\n \"error\": {}\n}" + } + ] } ], "description": "Statping contains multiple notifiers that will send you a notification whenever a service become offline, or online. You can create your own 3rd party notifier by reading more on the [Notifiers Wiki](https://github.com/statping/statping/wiki/Notifiers) on the Github repo.", @@ -3373,7 +4322,7 @@ { "listen": "prerequest", "script": { - "id": "bd5d8232-7ed7-4607-ab7c-14de85c3a033", + "id": "8f3b2e75-ce23-4294-b5bb-05b1248b9ef3", "type": "text/javascript", "exec": [ "" @@ -3383,7 +4332,7 @@ { "listen": "test", "script": { - "id": "ef420ba0-37dc-4ffc-b38f-a43ccca76606", + "id": "06653dbc-888b-4016-8964-82d25e0273e3", "type": "text/javascript", "exec": [ "" @@ -3402,7 +4351,7 @@ { "listen": "test", "script": { - "id": "3c484d1b-6e77-4084-b844-3ca77dc50108", + "id": "b2374cab-1ce8-4f9e-a2fa-f92477936cd4", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3480,7 +4429,7 @@ { "listen": "test", "script": { - "id": "12caf74a-61d7-4f6e-89b5-fca2f65464c4", + "id": "66307d95-1833-4786-a29a-40fc05153d09", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3583,7 +4532,7 @@ { "listen": "test", "script": { - "id": "c30cc333-53f4-4e9a-9c32-958c905ec163", + "id": "7e17e9cb-6750-411a-8a9a-335ece3b3cda", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3661,7 +4610,7 @@ { "listen": "test", "script": { - "id": "e9dd78cc-0f38-4516-bf82-38dd3451b2e7", + "id": "c89210ce-dfce-4acf-8bf5-f601f53d353e", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3693,7 +4642,10 @@ ], "body": { "mode": "raw", - "raw": "{\n \"title\": \"Updated Message\",\n \"description\": \"This message was updated\",\n \"start_on\": \"2022-11-17T03:28:16.323797-08:00\",\n \"end_on\": \"2022-11-17T05:13:16.323798-08:00\",\n \"service\": 1,\n \"notify_users\": true,\n \"notify_method\": \"email\",\n \"notify_before\": 3,\n \"notify_before_scale\": \"hour\"\n}" + "raw": "{\n \"title\": \"Updated Message\",\n \"description\": \"This message was updated\",\n \"start_on\": \"2022-11-17T03:28:16.323797-08:00\",\n \"end_on\": \"2022-11-17T05:13:16.323798-08:00\",\n \"service\": 1,\n \"notify_users\": true,\n \"notify_method\": \"email\",\n \"notify_before\": 3,\n \"notify_before_scale\": \"hour\"\n}", + "options": { + "raw": {} + } }, "url": { "raw": "{{endpoint}}/api/messages/{{message_id}}", @@ -3765,7 +4717,7 @@ { "listen": "test", "script": { - "id": "6cb2527f-41c2-4feb-9573-1e4d59efa116", + "id": "61a55ba9-d524-4509-a93f-679b5574182a", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3864,7 +4816,7 @@ { "listen": "prerequest", "script": { - "id": "8d24599b-f157-475b-9e30-06c1171c85bc", + "id": "b2160e12-ca83-4454-be33-7eac6f32e16b", "type": "text/javascript", "exec": [ "" @@ -3874,7 +4826,7 @@ { "listen": "test", "script": { - "id": "497c2428-fe8a-42c2-bf6f-8f2cdf959771", + "id": "a140fc05-3ec2-40dc-a5c5-93d055242995", "type": "text/javascript", "exec": [ "" @@ -3893,7 +4845,7 @@ { "listen": "test", "script": { - "id": "54bded63-de27-4839-8783-25874c35c3ea", + "id": "e94a6ff9-bbea-4947-9360-6302a29bdddd", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3972,7 +4924,7 @@ { "listen": "test", "script": { - "id": "af07a95b-1bf5-42c7-bd3f-a32f3ab2a264", + "id": "4d656189-d860-43d5-b9b9-d526c6d52338", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -4015,7 +4967,10 @@ ], "body": { "mode": "raw", - "raw": "{\n \"service_id\": 2,\n \"name\": \"Server Checkin\",\n \"interval\": 900,\n \"grace\": 60\n}" + "raw": "{\n \"service_id\": 2,\n \"name\": \"Server Checkin\",\n \"interval\": 900,\n \"grace\": 60\n}", + "options": { + "raw": {} + } }, "url": { "raw": "{{endpoint}}/api/checkins", @@ -4085,7 +5040,7 @@ { "listen": "test", "script": { - "id": "652a1c5b-5379-43c2-9cd8-ebd8f8dad0f6", + "id": "cb89fcee-0ae4-4496-a159-c214238965ab", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -4161,7 +5116,7 @@ { "listen": "test", "script": { - "id": "93ff6b86-368b-406f-9d75-07338714ebca", + "id": "25998408-3f55-4d42-ac4f-b6163c1fc0a5", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -4242,7 +5197,7 @@ { "listen": "test", "script": { - "id": "d3fdc6b9-d8ca-4634-a735-af8db0f31cef", + "id": "0ddca6d9-b1f9-49db-be8d-75fcab4cab0d", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -4276,7 +5231,10 @@ "header": [], "body": { "mode": "raw", - "raw": "" + "raw": "", + "options": { + "raw": {} + } }, "url": { "raw": "{{endpoint}}/api/checkins/{{checkin_id}}", @@ -4351,7 +5309,7 @@ { "listen": "prerequest", "script": { - "id": "fefe9fc9-8020-41ec-b20f-dd2c5ad951e9", + "id": "d880b73c-1edd-40d7-aac5-6ef0d2e2704b", "type": "text/javascript", "exec": [ "" @@ -4361,7 +5319,7 @@ { "listen": "test", "script": { - "id": "4a611b52-8ec2-4e26-8ed8-51f2729f93a1", + "id": "adf70343-e8f3-4162-8eeb-6fb71784ef57", "type": "text/javascript", "exec": [ "" @@ -4380,11 +5338,9 @@ { "listen": "test", "script": { - "id": "cf003eb2-e18e-46f0-bee2-2a9915525651", + "id": "11f52299-58b7-4a57-9842-252e2d8e139e", "exec": [ - "pm.test(\"Response is ok\", function () {", - " pm.response.to.have.status(200);", - "});" + "" ], "type": "text/javascript" } @@ -4424,11 +5380,9 @@ { "listen": "test", "script": { - "id": "8520bcc3-1176-4eb9-b22e-31169e093568", + "id": "8dace46e-1e0d-4d7c-90f0-c5a29cd2f0c0", "exec": [ - "pm.test(\"Response is ok\", function () {", - " pm.response.to.have.status(200);", - "});" + "" ], "type": "text/javascript" } @@ -4467,11 +5421,9 @@ { "listen": "test", "script": { - "id": "d9665e36-02b4-4c9f-b155-aded33b3936e", + "id": "b18f4b1d-3019-4b96-8203-d1876deab89f", "exec": [ - "pm.test(\"Response is ok\", function () {", - " pm.response.to.have.status(200);", - "});" + "" ], "type": "text/javascript" } @@ -4519,11 +5471,9 @@ { "listen": "test", "script": { - "id": "22213939-d2be-47fb-8c76-b8b4c4956b81", + "id": "5e59d318-3e11-44be-9d78-85398d35e9be", "exec": [ - "pm.test(\"Response is ok\", function () {", - " pm.response.to.have.status(200);", - "});" + "" ], "type": "text/javascript" } @@ -4609,7 +5559,7 @@ { "listen": "prerequest", "script": { - "id": "cb6d709c-85c1-4dc3-9434-04f817db23ea", + "id": "8512f9f2-50af-4c7c-90af-4feb43908ac9", "type": "text/javascript", "exec": [ "" @@ -4619,7 +5569,311 @@ { "listen": "test", "script": { - "id": "88b7bef2-103e-455c-a8f8-bce15c73d6d7", + "id": "f28d8c39-84fa-4e20-9bd9-e8f8a0158919", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "protocolProfileBehavior": {} + }, + { + "name": "oAuth", + "item": [ + { + "name": "Set Keys", + "event": [ + { + "listen": "test", + "script": { + "id": "3b2cf616-7e7d-4e11-beee-7027e0ed6dd2", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"update check\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.status).to.eql(\"success\");", + " pm.expect(jsonData.method).to.eql(\"update\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"gh_client_id\": \"githubid\",\n \"gh_client_secret\": \"githubsecret\",\n \"google_client_id\": \"googleid\",\n \"google_client_secret\": \"googlesecret\",\n \"oauth_domains\": \"gmail.com,yahoo.com,socialeck.com\",\n \"oauth_providers\": \"local,slack,google,github\",\n \"slack_client_id\": \"936045034737.1044972172659\",\n \"slack_client_secret\": \"05dd514efb382971e538a5561981e54a\",\n \"slack_team\": \"dev\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{endpoint}}/api/oauth", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "oauth" + ] + }, + "description": "This endpoint will return the last line in the logs." + }, + "response": [ + { + "name": "Statping Details", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Length", + "value": "398" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Sat, 02 May 2020 01:06:09 GMT" + } + ], + "cookie": [], + "body": "{\n \"admin\": false,\n \"allow_reports\": false,\n \"created_at\": \"2020-05-02T01:00:07.885973685Z\",\n \"description\": \"This data is only used to testing\",\n \"domain\": \"http://localhost:8080\",\n \"footer\": null,\n \"logged_in\": false,\n \"migration_id\": 1588381207,\n \"name\": \"Statping Sample Data\",\n \"setup\": true,\n \"started_on\": \"2020-05-02T01:00:14.255837864Z\",\n \"updated_at\": \"2020-05-02T01:00:12.731269305Z\",\n \"using_cdn\": false,\n \"version\": \"0.90.34\"\n}" + } + ] + }, + { + "name": "Get Keys", + "event": [ + { + "listen": "test", + "script": { + "id": "a3dd164d-56dc-43c9-80ae-ad42ced9542f", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "", + "pm.test(\"correct values\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.gh_client_id).to.eql(\"githubid\");", + " pm.expect(jsonData.gh_client_secret).to.eql(\"githubsecret\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api/oauth", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "oauth" + ] + }, + "description": "This endpoint will return the last line in the logs." + }, + "response": [ + { + "name": "Statping Details", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Length", + "value": "398" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Sat, 02 May 2020 01:06:09 GMT" + } + ], + "cookie": [], + "body": "{\n \"admin\": false,\n \"allow_reports\": false,\n \"created_at\": \"2020-05-02T01:00:07.885973685Z\",\n \"description\": \"This data is only used to testing\",\n \"domain\": \"http://localhost:8080\",\n \"footer\": null,\n \"logged_in\": false,\n \"migration_id\": 1588381207,\n \"name\": \"Statping Sample Data\",\n \"setup\": true,\n \"started_on\": \"2020-05-02T01:00:14.255837864Z\",\n \"updated_at\": \"2020-05-02T01:00:12.731269305Z\",\n \"using_cdn\": false,\n \"version\": \"0.90.34\"\n}" + } + ] + }, + { + "name": "Authenticate token", + "event": [ + { + "listen": "test", + "script": { + "id": "2d5f11de-4041-4667-b094-4e1934195649", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(500);", + "});", + "", + "pm.test(\"missing values\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.error).to.eql(\"oauth2: server response missing access_token\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "auth": { + "type": "noauth" + }, + "method": "GET", + "header": [], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "code", + "value": "936045034737.1125195726608.7440bec1a519b713bd3c39c4aaed46f5a4891878c1616d1a6ac2be3bc0cc9867", + "type": "text" + }, + { + "key": "state", + "value": "0", + "type": "text" + } + ] + }, + "url": { + "raw": "{{endpoint}}/oauth/slack", + "host": [ + "{{endpoint}}" + ], + "path": [ + "oauth", + "slack" + ] + }, + "description": "This endpoint will return the last line in the logs." + }, + "response": [ + { + "name": "Statping Details", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Length", + "value": "398" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Sat, 02 May 2020 01:06:09 GMT" + } + ], + "cookie": [], + "body": "{\n \"admin\": false,\n \"allow_reports\": false,\n \"created_at\": \"2020-05-02T01:00:07.885973685Z\",\n \"description\": \"This data is only used to testing\",\n \"domain\": \"http://localhost:8080\",\n \"footer\": null,\n \"logged_in\": false,\n \"migration_id\": 1588381207,\n \"name\": \"Statping Sample Data\",\n \"setup\": true,\n \"started_on\": \"2020-05-02T01:00:14.255837864Z\",\n \"updated_at\": \"2020-05-02T01:00:12.731269305Z\",\n \"using_cdn\": false,\n \"version\": \"0.90.34\"\n}" + } + ] + } + ], + "description": "You can allow other users to login through other services by using OAuth.\n\n- [Google OAuth](https://developers.google.com/identity/protocols/oauth2)\n- [Slack OAuth](https://api.slack.com/legacy/oauth)\n- [Github OAuth](https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/)\n\n### Redirect URL\nEach OAuth service has a dedicated redirect URL: `/oauth/{provider}`. Replace `{provider}` with google, slack, or github depending on which service you're using.", + "event": [ + { + "listen": "prerequest", + "script": { + "id": "2792fd81-5e3a-434b-8f51-992bea3a2b49", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "467bdaac-344d-451e-a4b4-825aec80ceef", "type": "text/javascript", "exec": [ "" @@ -4644,7 +5898,7 @@ { "listen": "prerequest", "script": { - "id": "e37b4946-9995-4fb5-88a9-39adb191d076", + "id": "a88caffc-d042-4f68-9757-3b5b3e628737", "type": "text/javascript", "exec": [ "" @@ -4654,12 +5908,13 @@ { "listen": "test", "script": { - "id": "8fa9bd45-c197-4751-baa6-c58143156aea", + "id": "dc71e455-8623-429d-890b-0cfc3bb9f8d1", "type": "text/javascript", "exec": [ "" ] } } - ] + ], + "protocolProfileBehavior": {} } \ No newline at end of file diff --git a/dev/postman_env_mysql.json b/dev/postman_env_mysql.json new file mode 100644 index 00000000..02284809 --- /dev/null +++ b/dev/postman_env_mysql.json @@ -0,0 +1,49 @@ +{ + "id": "0ff1dcd6-54f3-44a7-9c18-cc3c8e7df357", + "name": "Local Statping", + "values": [ + { + "key": "endpoint", + "value": "http://0.0.0.0:8585", + "enabled": true + }, + { + "key": "api_key", + "value": "demosecret123", + "enabled": true + }, + { + "key": "db_connection", + "value": "mysql", + "enabled": true + }, + { + "key": "db_host", + "value": "localhost", + "enabled": true + }, + { + "key": "db_user", + "value": "root", + "enabled": true + }, + { + "key": "db_password", + "value": "password123", + "enabled": true + }, + { + "key": "db_database", + "value": "statping", + "enabled": true + }, + { + "key": "db_port", + "value": "3306", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2020-05-18T20:44:05.571Z", + "_postman_exported_using": "Postman/7.24.0" +} diff --git a/dev/postman_env_postgres.json b/dev/postman_env_postgres.json new file mode 100644 index 00000000..6093018b --- /dev/null +++ b/dev/postman_env_postgres.json @@ -0,0 +1,49 @@ +{ + "id": "0ff1dcd6-54f3-44a7-9c18-cc3c8e7df357", + "name": "Local Statping", + "values": [ + { + "key": "endpoint", + "value": "http://0.0.0.0:8585", + "enabled": true + }, + { + "key": "api_key", + "value": "demosecret123", + "enabled": true + }, + { + "key": "db_connection", + "value": "postgres", + "enabled": true + }, + { + "key": "db_host", + "value": "localhost", + "enabled": true + }, + { + "key": "db_user", + "value": "root", + "enabled": true + }, + { + "key": "db_password", + "value": "password123", + "enabled": true + }, + { + "key": "db_database", + "value": "statping", + "enabled": true + }, + { + "key": "db_port", + "value": "5432", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2020-05-18T20:44:05.571Z", + "_postman_exported_using": "Postman/7.24.0" +} diff --git a/dev/postman_env_sqlite.json b/dev/postman_env_sqlite.json new file mode 100644 index 00000000..fcde08b5 --- /dev/null +++ b/dev/postman_env_sqlite.json @@ -0,0 +1,49 @@ +{ + "id": "0ff1dcd6-54f3-44a7-9c18-cc3c8e7df357", + "name": "Local Statping", + "values": [ + { + "key": "endpoint", + "value": "http://0.0.0.0:8585", + "enabled": true + }, + { + "key": "api_key", + "value": "demosecret123", + "enabled": true + }, + { + "key": "db_connection", + "value": "sqlite", + "enabled": true + }, + { + "key": "db_host", + "value": "localhost", + "enabled": true + }, + { + "key": "db_user", + "value": "root", + "enabled": true + }, + { + "key": "db_password", + "value": "password123", + "enabled": true + }, + { + "key": "db_database", + "value": "statping", + "enabled": true + }, + { + "key": "db_port", + "value": "3306", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2020-05-18T20:44:05.571Z", + "_postman_exported_using": "Postman/7.24.0" +} diff --git a/dev/postman_environment.json b/dev/postman_environment.json deleted file mode 100644 index ad4333ca..00000000 --- a/dev/postman_environment.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "id": "0ff1dcd6-54f3-44a7-9c18-cc3c8e7df357", - "name": "Local Statping", - "values": [ - { - "key": "endpoint", - "value": "http://127.0.0.1:8080", - "description": "", - "enabled": true - }, - { - "key": "api_key", - "value": "demosecret123", - "description": "", - "enabled": true - } - ], - "_postman_variable_scope": "environment", - "_postman_exported_at": "2018-11-17T16:55:15.031Z", - "_postman_exported_using": "Postman/6.5.2" -} diff --git a/dev/prometheus.yml b/dev/prometheus.yml index 8637d797..a8fea124 100644 --- a/dev/prometheus.yml +++ b/dev/prometheus.yml @@ -3,17 +3,11 @@ global: evaluation_interval: 15s scrape_configs: - - job_name: 'statping_local' - scrape_interval: 15s - bearer_token: 'samplesecret' - static_configs: - - targets: ['docker0:8585'] - - - job_name: 'statping' + - job_name: 'statping_sqlite' scrape_interval: 15s bearer_token: 'exampleapisecret' static_configs: - - targets: ['statping:8080'] + - targets: ['statping_sqlite:8080'] - job_name: 'statping_mysql' scrape_interval: 15s @@ -21,14 +15,14 @@ scrape_configs: static_configs: - targets: ['statping_mysql:8080'] + - job_name: 'statping_mariadb' + scrape_interval: 15s + bearer_token: 'exampleapisecret' + static_configs: + - targets: ['statping_mariadb:8080'] + - job_name: 'statping_postgres' scrape_interval: 15s bearer_token: 'exampleapisecret' static_configs: - targets: ['statping_postgres:8080'] - - - job_name: 'statping_dev' - scrape_interval: 15s - bearer_token: 'exampleapisecret' - static_configs: - - targets: ['statping_dev:8585'] diff --git a/dev/pwd-stack.yml b/dev/pwd-stack.yml index 602f5612..71c2a179 100644 --- a/dev/pwd-stack.yml +++ b/dev/pwd-stack.yml @@ -18,7 +18,7 @@ services: DOMAIN: http://localhost:8080 DESCRIPTION: This is a dev environment on SQLite! ADMIN_USER: admin - ADMIN_PASS: admin + ADMIN_PASSWORD: admin postgres: hostname: postgres diff --git a/frontend/config/webpack.config.common.js b/frontend/config/webpack.config.common.js index 5a85a3f7..ebc5c82a 100644 --- a/frontend/config/webpack.config.common.js +++ b/frontend/config/webpack.config.common.js @@ -22,7 +22,12 @@ const webpackConfig = { { test: /\.vue$/, loader: 'vue-loader', - include: [ helpers.root('src') ] + include: [ helpers.root('src') ], + options: { + loaders: { + i18n: '@kazupon/vue-i18n-loader' + } + } }, { test: /\.js$/, diff --git a/frontend/package.json b/frontend/package.json index 6b366b32..b672688d 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -36,6 +36,7 @@ "vue-cookies": "^1.7.0", "vue-flatpickr-component": "^8.1.5", "vue-github-button": "^1.1.2", + "vue-i18n": "^8.18.1", "vue-moment": "^4.1.0", "vue-observe-visibility": "^0.4.6", "vue-router": "~3.0", @@ -51,6 +52,7 @@ "@babel/plugin-syntax-import-meta": "~7.2", "@babel/polyfill": "~7.2", "@babel/preset-env": "^7.9.0", + "@kazupon/vue-i18n-loader": "^0.5.0", "@vue/babel-preset-app": "^4.1.2", "@vue/cli-plugin-babel": "^4.1.0", "@vue/cli-service": "^4.2.3", diff --git a/frontend/public/base.gohtml b/frontend/public/base.gohtml index 95564ce7..46e82bfb 100644 --- a/frontend/public/base.gohtml +++ b/frontend/public/base.gohtml @@ -7,14 +7,13 @@ + {{if USE_CDN}} - {{else}} - {{if USING_ASSETS}} diff --git a/frontend/public/favicon.ico b/frontend/public/favicon.ico index e8999029..004d10b3 100644 Binary files a/frontend/public/favicon.ico and b/frontend/public/favicon.ico differ diff --git a/frontend/public/index.html b/frontend/public/index.html index cf620e9a..a0fee432 100644 --- a/frontend/public/index.html +++ b/frontend/public/index.html @@ -5,6 +5,7 @@ + Statping diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 323a7651..8a8d0dad 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -6,7 +6,6 @@ diff --git a/frontend/src/components/Index/GroupServiceFailures.vue b/frontend/src/components/Index/GroupServiceFailures.vue index 8aff79a5..72ad7bda 100644 --- a/frontend/src/components/Index/GroupServiceFailures.vue +++ b/frontend/src/components/Index/GroupServiceFailures.vue @@ -6,11 +6,11 @@
-
30 Days Ago
-
+
30 Days Ago
+
{{service_txt}}
-
Today
+
Today
@@ -36,14 +36,7 @@ export default { }, computed: { service_txt() { - const s = this.service - if (!s.online) { - if (!this.toUnix(this.parseISO(s.last_success))) { - return `Always Offline` - } - return `Offline for ${this.ago(s.last_success)}` - } - return `${this.service.online_24_hours}% Uptime` + return this.smallText(this.service) } }, mounted () { diff --git a/frontend/src/components/Service/ServiceBlock.vue b/frontend/src/components/Service/ServiceBlock.vue index 3141d8cd..1ea76bf6 100644 --- a/frontend/src/components/Service/ServiceBlock.vue +++ b/frontend/src/components/Service/ServiceBlock.vue @@ -223,18 +223,6 @@ export default { this.stats.low_ping.chart = pingData.chart; this.stats.low_ping.value = this.humanTime(pingData.low); }, - smallText(s) { - const incidents = s.incidents - if (s.online) { - return `Checked ${this.ago(s.last_success)} ago` - } else { - const last = s.last_failure - if (last) { - return `Offline, last error: ${last} ${this.ago(last.created_at)}` - } - return `Service has been offline for ${this.ago(s.last_success)}` - } - }, visibleChart(isVisible, entry) { if (isVisible && !this.visible) { this.visible = true diff --git a/frontend/src/forms/CoreSettings.vue b/frontend/src/forms/CoreSettings.vue index 08d42ebd..fef485d0 100644 --- a/frontend/src/forms/CoreSettings.vue +++ b/frontend/src/forms/CoreSettings.vue @@ -31,6 +31,18 @@ HTML is allowed inside the footer +
+ + + HTML is allowed inside the footer +
+
diff --git a/frontend/src/forms/OAuth.vue b/frontend/src/forms/OAuth.vue index 99e63ccd..ca0c7a5d 100644 --- a/frontend/src/forms/OAuth.vue +++ b/frontend/src/forms/OAuth.vue @@ -51,7 +51,7 @@
- +
@@ -90,7 +90,7 @@
- +
@@ -136,7 +136,7 @@
- +
diff --git a/frontend/src/forms/Service.vue b/frontend/src/forms/Service.vue index 1dfb926c..306f61f4 100644 --- a/frontend/src/forms/Service.vue +++ b/frontend/src/forms/Service.vue @@ -1,5 +1,5 @@