diff --git a/adserver/cache/cache.go b/adserver/cache/cache.go index 47739f9..58193a0 100644 --- a/adserver/cache/cache.go +++ b/adserver/cache/cache.go @@ -47,4 +47,4 @@ func (r *AdServerCache) Add(key string) { if err != nil { log.Println("could not insert " + key + " in adserver redis: " + err.Error()) } -} +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index ba734e9..4f30a4a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -181,18 +181,32 @@ services: - REDIS_ADDR=redis:6379 ports: - "9121:9121" + depends_on: + - redis kafka-exporter: image: danielqsj/kafka-exporter:v1.7.0 command: - --kafka.server=kafka:9092 ports: - "9308:9308" + depends_on: + - kafka postgres-exporter: image: prometheuscommunity/postgres-exporter:v0.15.0 environment: - DATA_SOURCE_NAME=postgresql://postgres:1234@db:5432/mini_yektanet_db?sslmode=disable ports: - "9187:9187" + depends_on: + - db + zookeeper-exporter: + image: dabealu/zookeeper-exporter:v0.1.13 + environment: + - ZK_SERVER=zookeeper:2181 + ports: + - "9141:9141" + depends_on: + - zookeeper volumes: panel_static: diff --git a/panel/grafana/grafana.go b/panel/grafana/grafana.go new file mode 100644 index 0000000..c37b86f --- /dev/null +++ b/panel/grafana/grafana.go @@ -0,0 +1,78 @@ +package grafana + +import ( + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promauto" + "YellowBloomKnapsack/mini-yektanet/common/grafana" +) + +var ( + ActiveAdsCount = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "active_ads_count", + Help: "The total number of active ads", + }) + + AdvertisersCount = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "advertisers_count", + Help: "The total number of advertisers", + }) + + PublishersCount = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "publishers_count", + Help: "The total number of publishers", + }) + + ImpressionCount = promauto.NewCounter(prometheus.CounterOpts{ + Name: "impression_count", + Help: "The total number of impressions", + }) + + ClickCount = promauto.NewCounter(prometheus.CounterOpts{ + Name: "click_count", + Help: "The total number of clicks", + }) + + TotalRevenue = promauto.NewCounter(prometheus.CounterOpts{ + Name: "total_revenue", + Help: "The total revenue generated", + }) + + NumberOfBids = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "number_bids", + Help: "total number of bids", + }) + + AverageBid = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "average_bid", + Help: "The average bid amount", + }) + + TransactionCount = promauto.NewCounterVec(prometheus.CounterOpts{ + Name: "transaction_count", + Help: "The number of transactions", + }, []string{"status"}) + + TotalAdvertiserBalance = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "total_advertiser_balance", + Help: "The total balance of all advertisers", + }) + + TotalPublisherBalance = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "total_publisher_balance", + Help: "The total balance of all publishers", + }) +) + +func InitializeMetrics() { + ActiveAdsCount.Set(0) + AdvertisersCount.Set(0) + PublishersCount.Set(0) + ImpressionCount.Set(0) + ClickCount.Set(0) + TotalRevenue.Set(0) + NumberOfBids.Set(0) + AverageBid.Set(0) + TransactionCount.Set(0) + TotalAdvertiserBalance.Set(0) + TotalPublisherBalance.Set(0) +} \ No newline at end of file diff --git a/prometheus.yml b/prometheus.yml index 5bc7a6a..9059297 100644 --- a/prometheus.yml +++ b/prometheus.yml @@ -22,6 +22,10 @@ scrape_configs: - job_name: 'postgres' static_configs: - targets: ['postgres-exporter:9187'] + + - job_name: 'zookeeper' + static_configs: + - targets: ['zookeeper-exporter:9141'] # - job_name: 'redis' # static_configs: # - targets: ['redis:6379']