diff --git a/05-osm-usage.md b/05-osm-usage.md index b84c91ae072c8871b98290a1f360f8fa75e0b92b..5620f07c6fb8127b7b932d5af7c549e3742762b9 100644 --- a/05-osm-usage.md +++ b/05-osm-usage.md @@ -2125,6 +2125,101 @@ From the UI: ![VM Migration](assets/500px-VM_Migration.png) +## How to Achieve Automated VNF Scaling in OSM using Prometheus Exporter and Service KPIs +When we launch the VNF using OSM then vdu will get's deployed in VIM let's say Openstack. Then OSM runs cloud-init Day-0 Operation and with that Exporter is installed and invoked in the VDU. Resulting Prometheus Exporter exposes the metric to be scraped by Prometheus independently and monitor and trigger +Alert. Based on that alert, OSM auto scales up/down the VNF. + +- **Highlights of the feature.** + - `Fine-Grained VNF Monitoring:` + - Exporters running on VDUs (Virtual Deployment Units) expose detailed metrics about the VNF's performance. + - `Commercial VNF`: + - Most commercial VNFs come with node exporters. + - `Custom Applications:` + - You can easily create custom exporters to expose metrics from your own applications or those without built-in instrumentation. + - `Diverse Systems:` + - Exporters exist for a vast array of systems and technologies, including databases, message queues, web servers, hardware, and cloud services. + - `Pull-Based Model:` + - Prometheus pulls metrics from exporters, reducing the overhead on your systems compared to push-based models. + +![Alt text](assets/service_kpi-nsga.png) + +### We will go step-by-step how to achieve this one touch automation. + 1. How to do VNFD modeling for autoscaling + 2. How to structure Prometheus job template + 3. How to structure Day-0 operation in cloud-config.txt file + 4. Verify the Prometheus job template in db and check for metrics in Prometheus + +**1. How to do VNFD modeling for autoscaling** +- In below vnfd example `exporters-endpoints`, `scaling-aspect`, `cloud-init-file`, and `monitoring-parameter` all parameters are used to define your intent and OSM will take care of instantiation and Autoscaling based on the threshold defined. +```yaml +vnfd: + description: A basic VNF descriptor w/ one VDU + df: + exporters-endpoints: # path where metric is exposed by exporter + metric-path: /metrics + metric-port: 9100 + external-connection-point-ref: vnf-cp0-ext + scaling-aspect: # define the scaling threshold + - aspect-delta-details: + id: vdu_autoscale + max-scale-level: 1 + name: vdu_autoscale + scaling-policy: + - cooldown-time: 3 + name: cpu_util_above_threshold + scaling-criteria: + - name: cpu_util_above_threshold + scale-in-relational-operation: LT + scale-in-threshold: 47900000 + scale-out-relational-operation: GT + scale-out-threshold: 48000000 + vnf-monitoring-param-ref: vnf_cpu_util + scaling-type: automatic + threshold-time: 3 + vdu: + - cloud-init-file: cloud-config.txt # definition of Day-0 operation + supplemental-boot-data: + boot-data-drive: true + monitoring-parameter: # define the actual metrics to be scraped and monitored + - id: vnf_cpu_util + name: vnf_cpu_util + performance-metric: kpi_node_memory_Slab_bytes # prefix "kpi_" on actual metric name +``` +**2. How to structure Prometheus job template** +- Below mentioned Prometheus job template is used to create a prometheus job in mongo db, You have to save below content in `prometheus-job-template.j2` and put inside exporter-endpoint directory. +```yaml +- job_name: '{{ JOB_NAME }}' + static_configs: + - targets: + - {{ TARGET_IP }}:{{TARGET_PORT}} + metrics_path: {{ METRIC_PATH }} + metric_relabel_configs: + - source_labels: [__name__] + regex: '(.*)' + replacement: 'osm_${1}' + target_label: __name__ +``` +**3. How to structure Day-0 operation in cloud-config.txt file** +- Add below content to `cloud-config.txt` file a place it inside cloud_init directory. +- Here we are defining the which prometheus exporter to be downloaded and run by OSM as Day-0 operation. +```text +runcmd: +- wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz +- tar xzvf node_exporter-0.18.1.linux-amd64.tar.gz +- nohup ./node_exporter-0.18.1.linux-amd64/node_exporter & +``` + +- *Finally your descriptor should look like this.* +![Alt text](assets/service_kpi_vnfd.png) + +**4. Verify the Prometheus job template in db and check for metrics in Prometheus** +- Now upload the vnfd and nsd in osm and launch the NS. +- Verify the prometheus job template in mongodb +- Check in Prometheus service KPI metric is coming + +**Conclusion** +- In above guid we have learned how we can achieve Autoscaling of VNF's in OSM using Prometheus Exporters and Service KPI metric. + ## How to deploy a VNF that comes with a Prometheus exporter The Service KPI (Key Performance Indicator) feature in OSM enables efficient monitoring and assurance of network service performance. With the introduction of the Exporter Endpoint, users can now collect Service KPIs directly from VNFs that come with a Prometheus Exporter. @@ -2156,7 +2251,7 @@ vnfd: ### How to check that the VNF exporter endpoints are exposing their metrics - Instantiate the NS (Network Service) within the OSM environment using the onboarded VNF package. -- Confirm that the Service KPI metrics are flowing seamlessly from the VNF instances to OSM-Prometheus, whose graphical interface can be visited at the URL . +- Confirm that the Service KPI metrics are flowing seamlessly from the VNF instances to OSM-Prometheus, whose graphical interface can be visited at the URL . ## How to prepare a NS that will use static Dual-Stack IP configuration for VNF connection points diff --git a/assets/service_kpi-nsga.png b/assets/service_kpi-nsga.png new file mode 100644 index 0000000000000000000000000000000000000000..8f91ac986e7201c1bc239350f80c11cc46b3a593 Binary files /dev/null and b/assets/service_kpi-nsga.png differ diff --git a/assets/service_kpi_vnfd.png b/assets/service_kpi_vnfd.png new file mode 100644 index 0000000000000000000000000000000000000000..282f69359b6bb210c4f319c84bc5eddc9c716b88 Binary files /dev/null and b/assets/service_kpi_vnfd.png differ