"sync"
"time"
+ "github.com/prometheus/client_golang/prometheus"
+ "github.com/prometheus/client_golang/prometheus/promhttp"
+
"github.com/gorilla/mux"
"oransc.org/usecase/oduclosedloop/messages"
policyDedicatedRatio int
}
-var data []*SliceAssuranceInformation
-var messagesToSend []messages.Measurement
+var (
+ data []*SliceAssuranceInformation
+ messagesToSend []messages.Measurement
+ metric = prometheus.NewGaugeVec(prometheus.GaugeOpts{
+ Name: "rapp_slice_assurance_metric",
+ Help: "Duration of the last request call.",
+ }, []string{"MeasurementTypeInstanceReference", "unit"})
+)
func loadData() {
lines, err := GetCsvFromFile("test-data.csv")
policyDedicatedRatio: toInt(line[9]),
}
data = append(data, &sai)
+ metric.WithLabelValues(getMeasTypeInstanceRef(&sai), "kbit/s").Set(float64(THRESHOLD_TPUT))
}
}
wg := new(sync.WaitGroup)
wg.Add(2)
+ prometheus.Register(metric)
+
go func() {
r := mux.NewRouter()
go func() {
r := mux.NewRouter()
+ r.Handle("/metrics", promhttp.Handler())
r.HandleFunc("/events/unauthenticated.VES_O_RAN_SC_HELLO_WORLD_PM_STREAMING_OUTPUT/myG/C1", sendDmaapMRMessages).Methods(http.MethodGet)
fmt.Println("Starting DmaapMR stub on port: ", *portDmaapMR)
log.Info("Send Dmaap messages")
entry := data[rand.Intn(5)]
+ changeMetric(entry)
+
maxTput := THRESHOLD_TPUT + 100
randomTput := rand.Intn(maxTput-THRESHOLD_TPUT+1) + THRESHOLD_TPUT
if randomTput%3 == 0 {
func generateMeasurementEntry(entry *SliceAssuranceInformation) messages.Measurement {
- measurementTypeInstanceReference := "/o-ran-sc-du-hello-world:network-function/distributed-unit-functions[id='" + entry.duId + "']/cell[id='" + entry.cellId + "']/supported-measurements[performance-measurement-type='(urn:o-ran-sc:yang:o-ran-sc-du-hello-world?revision=2021-11-23)" + entry.metricName + "']/supported-snssai-subcounter-instances[slice-differentiator='" + strconv.Itoa(entry.sd) + "'][slice-service-type='" + strconv.Itoa(entry.sst) + "']"
+ measurementTypeInstanceReference := getMeasTypeInstanceRef(entry)
meas := messages.Measurement{
MeasurementTypeInstanceReference: measurementTypeInstanceReference,
}
return meas
}
+
+func getMeasTypeInstanceRef(entry *SliceAssuranceInformation) string {
+ return "/o-ran-sc-du-hello-world:network-function/distributed-unit-functions[id='" + entry.duId + "']/cell[id='" + entry.cellId + "']/supported-measurements[performance-measurement-type='(urn:o-ran-sc:yang:o-ran-sc-du-hello-world?revision=2021-11-23)" + entry.metricName + "']/supported-snssai-subcounter-instances[slice-differentiator='" + strconv.Itoa(entry.sd) + "'][slice-service-type='" + strconv.Itoa(entry.sst) + "']"
+}
+
+func changeMetric(entry *SliceAssuranceInformation) {
+ min := -5
+ max := 5
+ tmpVal := rand.Intn(max-min) + min
+ log.Infof("Adding %v to cell: %v, diff: %v ", tmpVal, entry.cellId, strconv.Itoa(entry.sd))
+ metric.WithLabelValues(getMeasTypeInstanceRef(entry), "kbit/s").Add(float64(tmpVal))
+
+}