Skip to content

srg-bnd/observator

Repository files navigation

Observator

Metrics collection and alerting service

go report card test status

Getting Started

Dependencies:

  • Go 1.23
  • PostgreSQL
  • Linux or macOS platform

Startup

Server

To build a server, run in the terminal:

cd cmd/server && go run . # in the root directory of the project

To startup the server, run in the terminal:

./cmd/server/server # in the root directory of the project

Build and compilation flags (ldflags):

  • buildVersion: any string (example, -X 'main.buildVersion=v0.0.1')
  • buildDate: $(date -u '+%Y/%m/%d %H:%M:%S')'
  • buildCommit: $(git rev-parse --short HEAD || echo 'unknown')'
Envs & flags
  • ADDRESS | -a – address and port to run server. Default :8080
  • DATABASE_DSN | -d – DB connection address
  • LOG_LEVEL | -l – log level. Default info
  • FILE_STORAGE_PATH | -f – file storage path. Default ./temp.storage.db
  • RESTORE | -r – load data from storage. Default true
  • STORE_INTERVAL | -i – store interval in seconds (zero for sync). Default 300

Agent

To build a agent, run in the terminal:

cd cmd/agent && go run . # in the root directory of the project

To startup the agent, run in the terminal:

./cmd/server/agent # in the root directory of the project

Build and compilation flags (-ldflags):

  • buildVersion: any string (example, -X 'main.buildVersion=v0.0.1')
  • buildDate: $(date -u '+%Y/%m/%d %H:%M:%S')'
  • buildCommit: $(git rev-parse --short HEAD || echo 'unknown')'
Envs & flags
  • ADDRESS | -a – address and port to run agent. Default localhost:8080
  • KEY | -k – encryption key
  • POLL_INTERVAL | -p – frequency (seconds) of metric polling. Default 2
  • RATE_LIMIT | -l – number of simultaneous outgoing requests to the server. Default 1
  • REPORT_INTERVAL | -r – frequency (seconds) of sending values to the server. Default 10

Development

Updating the template

To be able to receive updates to autotests and other parts of the template, run the command:

git remote add -m main template https://github.com/Yandex-Practicum/go-musthave-metrics-tpl.git

To update the autotest code, run the command:

git fetch template && git checkout template/main .github

Then add the received changes to your repository.

Launching autotests

To successfully run autotests, name the branches iter<number>, where <number> is the sequence number of the increment. For example, in the branch named iter4, autotests will be launched for increments from the first to the fourth.

When you merge a branch with an increment into the main branch main, all autotests will be run.

Read more about local and automatic startup in README autotests.

About

Metrics collection and alerting service

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published