In your application you typically use a prometeheus client library, but you can also track metrics yourself and export them to your own http-metrics-endpoint ofcourse.
Let's say we made an application that is processing something and you want to export one metric about how many objects were processed in total (since the app has been started). Another metric could be how many threads are currently working on processing something. Both are integers we can export via a http-metrics-endpoint for prometheus. Looking like this:
myapp_processed_total 23
myapp_processing_current_threads 8
Since we know the first myapp_processed_total is counting only upwards we might want to declare it as a Counter. The second one myapp_processing_current_threads can move up and down to indicate how many threads are currently in use. We might want to declare it as a gauge.
On our http-metrics-endpoint these are simply "comments" or annotations with # TYPE:
# TYPE myapp_processed_total counter
myapp_processed_total 23
# TYPE myapp_processing_current_threads gauge
myapp_processing_current_threads 8
Prometheus or even more important another administrator can use that information to create meaningful dashboards on the collected data, read the annotations with mouse hovering, query with rate()-function on counters but not on gauges for example... If you do the metrics from scratch both are just numbers though. But it sure is good practice to add the #TYPE information (and the # HELP information too) for further usage of your metrics.
Subresults can be defined with labels/key-value-tags in curly brakets b.t.w. For example when we want to differentiate between how many objects are processed successfully and how many are processed and aborted due to an error we might want to do something like this:
# HELP myapp_processed_total some useful information here
# TYPE myapp_processed_total counter
myapp_processed_total{status="success"} 20
myapp_processed_total{status="failure"} 3
And another administrator might create meaningful dashboards and queries on your metrics data later.
To summarize:
- yes both counters and gauges are just numbers in your application
- but it helps along in further processing of your metric to specify the type
- maybe use an existing prometheus client library