Metrics from Local Apps

As described in the Monitoring Overview, you can obtain metrics from an application run outside the cluster, but on the same machine. The main steps to see metrics from a local app include:

  1. Run app to verify
  2. Find Virtual Box bridge IP
  3. Create Kubernetes Service object
  4. View metrics

Run app to verify

Make sure that your project is set up to provide metrics as described in
Setting Up Monitoring. Run the application to verify that the application process is up and is producing metrics.

For example, let’s assume you’ve started an application with sbt run that is exporting Lightbend Telemetry via the cinnamon-metrics port at http://localhost:9001/metrics. Pointing a browser at that url might yield something like the following:

# HELP self_node_node_unable_to_join_event Node unable to join event
# TYPE self_node_node_unable_to_join_event gauge
self_node_node_unable_to_join_event{self_node="ShoppingCartApp@localhost:2551",application="com.lightbend.esdemos.shoppingcartapp.ShoppingCartApp",host="MacBook-Pro.local",} 0.0
# HELP jvm_pools_Code_Cache_used pools.Code-Cache.used
# TYPE jvm_pools_Code_Cache_used gauge
jvm_pools_Code_Cache_used{application="com.lightbend.esdemos.shoppingcartapp.ShoppingCartApp",host="MacBook-Pro.local",} 5619456.0
# HELP jvm_pools_PS_Eden_Space_usage pools.PS-Eden-Space.usage
# TYPE jvm_pools_PS_Eden_Space_usage gauge
jvm_pools_PS_Eden_Space_usage{application="com.lightbend.esdemos.shoppingcartapp.ShoppingCartApp",host="MacBook-Pro.local",} 0.031576853648024865

Find VirtualBox bridge IP

After you are sure that the application is exporting metrics, find the local IP address for VirtualBox. This IP serves as the bridge between the processes running within Minikube and the localhost. On Mac and Linux machines, run ifconfig, which yields something like the following and identifies the VirtualBox IP address:

utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
	inet6 fe80::8154:3d9e:faf0:57cc%utun1 prefixlen 64 scopeid 0x13 
	nd6 options=201<PERFORMNUD,DAD>
	ether 0a:00:27:00:00:00 
	inet netmask 0xffffff00 broadcast

Create Kubernetes Service object

Continuing with the example in the previous section, the VirtualBox IP is Create a Kubernetes Service descriptor file with the following contents, substituting your own application name and port numbers where necessary.

For example, create a myapp-local.yaml file:

apiVersion: v1
kind: Service
  name: myapp-local
    "": "true"
    "": http
    "": "/metrics"
    "": "9001"
    - name: metrics
      protocol: TCP
      port: 9001
      targetPort: 9001
apiVersion: v1
kind: Endpoints
  name: myapp-local
  - addresses:
      -  ip:
      - name: metrics
        protocol: TCP
        port: 9001

Then create these resources in Minikube by applying the file:

kubtctl apply -f myapp-local.yaml

View metrics

From the Console main page, click the ‘Grafana’ icon in the upper left corner.

Then you should be able to go to the appropriate dashboard to view your application metrics, or create a new custom dashboard for that purpose.