| 
 | 1 | +<!--  | 
 | 2 | +SPDX-FileCopyrightText: Copyright 2022-2025 SAP SE or an SAP affiliate company and andromeda contributors  | 
 | 3 | +
  | 
 | 4 | +SPDX-License-Identifier: Apache-2.0  | 
 | 5 | +-->  | 
 | 6 | + | 
 | 7 | +# `andromeda-akamai-reports` app  | 
 | 8 | + | 
 | 9 | +This worker will bind a Prometheus HTTP to `0.0.0.0:9090` (or the host and port provided by `PROMETHEUS_LISTEN`) and register a collector (`AndromedaAkamaiCollector`) that implements the `prometheus.Collector` interface. Whenever its `/metrics` endpoint is requested, Prometheus invokes `Collect()`, which in turn:  | 
 | 10 | + | 
 | 11 | +* Iterates over each property using the Akamai GTM API  | 
 | 12 | +* For each property...  | 
 | 13 | +  * Queries the Akamai GTM API for its [traffic report][traffic-report]  | 
 | 14 | +  * Retrieves its respective Keystone project ID from the Andromeda database  | 
 | 15 | +  * Writes the results of the API call to two gauge metrics:  | 
 | 16 | +    * `andromeda_akamai_requests_5m`  | 
 | 17 | +    * `andromeda_akamai_status_5m`  | 
 | 18 | + | 
 | 19 | +[traffic-report]: <https://techdocs.akamai.com/gtm-reporting/reference/get-traffic-property>  | 
 | 20 | + | 
 | 21 | +The Akamai metrics will be exposed at <http://localhost:9091/metrics>.  | 
 | 22 | + | 
 | 23 | +## Manually testing the main flow  | 
 | 24 | + | 
 | 25 | +Ensure the `akamai.yaml` file points to the desired Akamai domain (`akamai.domain` property).  | 
 | 26 | + | 
 | 27 | +Ensure that, for each property/domain/server combination that you'd like to test for, there's one respective `datacenter` table record in place. Navigate to the Akamai property details page and copy the the server UUID you'd like to test. Then, create a record in the local Andromeda `datacenter` table by providing some value (a real Keystone project ID is not necessary) for `datacenter.project_id` and  the Akamai property server UUID for `datacenter.id`:  | 
 | 28 | + | 
 | 29 | +```sql  | 
 | 30 | +INSERT INTO datacenter (id, project_id, provider, admin_state_up) VALUES  | 
 | 31 | +    ("...", "...", "akamai", 1);  | 
 | 32 | +```  | 
 | 33 | + | 
 | 34 | +On shell 1, start the RPC server.  | 
 | 35 | + | 
 | 36 | +```sh  | 
 | 37 | +go run cmd/andromemeda-server/main.go \  | 
 | 38 | +    --config-file ./tmp/andromeda.yaml \  | 
 | 39 | +    --config-file ./tmp/akamai.yaml  | 
 | 40 | +```  | 
 | 41 | + | 
 | 42 | +On Shell 2, start the Akamai Reports app:  | 
 | 43 | + | 
 | 44 | +```sh  | 
 | 45 | +export PROMETHEUS_LISTEN=0.0.0.0:9091  | 
 | 46 | +go run cmd/andromemeda-akamai-reports/main.go \  | 
 | 47 | +    --config-file ./tmp/andromeda.yaml \  | 
 | 48 | +    --config-file ./tmp/akamai.yaml  | 
 | 49 | +```  | 
 | 50 | + | 
 | 51 | +In order for Prometheus to invoke the Andromeda Akamai Collector, either browse or curl the `/metrics` endpoint:  | 
 | 52 | + | 
 | 53 | +```sh  | 
 | 54 | +curl http://0.0.0.0:9091/metrics | grep '_5m'  | 
 | 55 | +```  | 
 | 56 | + | 
 | 57 | +The output should include data for both `andromeda_akamai_requests_5m` and `andromeda_akamai_status_5m` custom metrics.  | 
0 commit comments