Main Steps
- Set Google Service Account
- Create Endpoint from Client Application
- Test the connection of the Prometheus URL
- Configure data source with Prometheus type on Grafana
- Explore the metrics
Step 1 Set Google project ID and Google Service Account
- Google Cloud Project ID is used to access Metrics and access Private BigAnimal Clusters.
-
Google Service Account is used to access Logs. Create one if you don't have one. Use the email address of the Service Account, for example
Step 2 Create Endpoint from Client Application
Go to your GCP project, here is development-data
2.1 Get VPC info
If there is no existing VM in GCP, you are recommended to create a VM in the same region as BigAnimal Cluster.
If the VM is running, then go to your VM, Network Interface - Network is your VPC, (below default is my VM’s VPC)
2.2 Create an endpoint with VPC
Go to your GCP project, here is development-data
- Go to Private Service Connect - CONNECTED ENDPOINTS - + CONNECT ENDPOINT
- Target: Published Service, and paste Service Attachment URL from Cluster - Connect
- Endpoint Name: use BigAnimal cluster ID (for example p-zxvvj29eca)
- Choose the VPC(of your VM) and select the subnet (if no subnet is available, then please check VPC requirement below )
- Create an IP address, or choose an existing IP that is not used by the other endpoints
-
Enable Global Access – Please note, if your VM is running in a different region from BigAnimal, then Global Access should be enabled.
- Create the endpoint.
- Check the endpoint status is accepted and get the IP address
Step 3: Test the connection of the Prometheus URL
Firstly the Prometheus URL can be used from a VM at the same VPC:
The below command returns all the metric names
curl http://p-r5w2xzrm5m-metrics.private.pg.biganimal.io:8080/api/v1/series | jq .
Query one metrics:
curl -s --data-urlencode 'query=cnp_backends_waiting_total' http://p-xm9sbs62ej.metrics.pg.biganimal.io:8080/api/v1/query | jq .data.result
[
{
"__name__": "cnp_pg_stat_database_tup_updated",
"aks_cluster_name": "dp-bahbiganimal-gke-europewest1-1",
"cloud_provider": "gcp",
"cluster": "p-r5w2xzrm5m",
"container": "postgres",
"datname": "postgres",
"endpoint": "metrics",
"instance": "10.245.128.7:9187",
"job": "monitoring/pg-cluster",
"namespace": "p-r5w2xzrm5m",
"pod": "p-r5w2xzrm5m-1",
"prometheus": "monitoring/k8s",
"role": "primary",
"telegraf_scrape_interval": "2m"
}
Step 4: Configure data source with Prometheus type on Grafana
Go to Grafana console and click Configuration - Data Sources from the navigation pane on the left:
Click "Add data source" then search Prometheus:
Input the Prometheus URL, leave all others as default then test the data source:
Step 5 Explore the metrics
Now you can explore the metrics in Grafana and create your dashboard.
If you need some dashboard templates, please contact BigAnimal Support