mirror of
https://github.com/mii443/prometheus-android-exporter.git
synced 2025-08-22 15:15:35 +00:00
wip
This commit is contained in:
@ -16,6 +16,11 @@ to run as ROOT. Exposes various hardware sensor metrics.
|
||||
|
||||
# Client
|
||||
|
||||
## To format code in android studio
|
||||
```
|
||||
CTRL + SHIFT + ALT + L
|
||||
```
|
||||
|
||||
## File configuration
|
||||
Client application is configurable via a configuration file.
|
||||
Place such file on your android device at a following path:
|
||||
|
@ -22,18 +22,35 @@ data class RemoteWriteConfiguration(
|
||||
val performScrape: () -> String, //TODO this class needs it structured in objects
|
||||
)
|
||||
|
||||
//TODO implement this thing
|
||||
class RemoteWriteSender(private val config: RemoteWriteConfiguration) {
|
||||
|
||||
//TODO implement this thing
|
||||
|
||||
private fun getRequestBody(): ByteArray {
|
||||
val label: Label = Label.newBuilder()
|
||||
.setName("labelNameTest")
|
||||
.setValue("labelValueTest").build()
|
||||
val label1: Label = Label.newBuilder()
|
||||
.setName("code")
|
||||
.setValue("200").build()
|
||||
|
||||
val nameLabel: Label = Label.newBuilder()
|
||||
val label2: Label = Label.newBuilder()
|
||||
.setName("handler")
|
||||
.setValue("/static/*filepath").build()
|
||||
|
||||
val label3: Label = Label.newBuilder()
|
||||
.setName("instance")
|
||||
.setValue("localhost:9090").build()
|
||||
|
||||
val label4: Label = Label.newBuilder()
|
||||
.setName("job")
|
||||
.setValue("prometheus").build()
|
||||
|
||||
val label5: Label = Label.newBuilder()
|
||||
.setName("__name__")
|
||||
.setValue("testremotewritemetriccccccccvv")
|
||||
.setValue("prometheus_http_requests_total")
|
||||
.build()
|
||||
|
||||
val specialLabel: Label = Label.newBuilder()
|
||||
.setName("prometheus_android_exporter")
|
||||
.setValue("remote_written")
|
||||
.build()
|
||||
|
||||
val sample: RemoteWrite.Sample = RemoteWrite.Sample.newBuilder()
|
||||
@ -41,8 +58,7 @@ class RemoteWriteSender(private val config: RemoteWriteConfiguration) {
|
||||
.setTimestamp(System.currentTimeMillis()).build()
|
||||
|
||||
val timeSeries: TimeSeries = TimeSeries.newBuilder()
|
||||
.addLabels(label)
|
||||
.addLabels(nameLabel)
|
||||
.addAllLabels(listOf(label1, label2, label3, label4, label5, specialLabel))
|
||||
.addSamples(sample)
|
||||
.build()
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.birdthedeveloper.prometheus.android.prometheus.android.exporter.worker
|
||||
|
||||
private const val TAG = "SCRAPE_RECORDER"
|
||||
|
||||
//TODO implement this thing
|
||||
// mutex with last scraped time
|
||||
class ScrapeRecorder{
|
||||
|
||||
//TODO mutex variable if mode is {pushprox / prometheus server} or {remote write}
|
||||
//TODO go back to mode {pushprox / prometheus server} only after N succesfull scrapes and no failures
|
||||
|
||||
fun countSuccesfullScrape(){
|
||||
//TODO implement this thing
|
||||
// write to mutex that scrape has happend at this current time
|
||||
// set timer to 2 x remote_write_scrape_interval seconds to check if next scrape has happened
|
||||
}
|
||||
|
||||
private fun onTimerTick(){
|
||||
//TODO implement this
|
||||
// check if other scrape has happened
|
||||
// if no scrape happened, go to mode {remote write}
|
||||
//
|
||||
|
||||
//TODO finite state machine of this stuff !!!
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user