Skip to content

Commit

Permalink
feat(besu): enable prometheus for besu node metrics
Browse files Browse the repository at this point in the history
prometheus server deployments for individual organizations

fixes hyperledger#2290

Signed-off-by: saikumarbommakanti <sai.kumar.bommakanti@accenture.com>
  • Loading branch information
saikumarbommakanti committed Aug 3, 2023
1 parent cc52101 commit 19125c3
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
27 changes: 27 additions & 0 deletions platforms/hyperledger-besu/configuration/deploy-network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,33 @@
when:
- item.type == 'member'

# This role deploy prometheus along with targets
- name: Deploy prometheus server
include_role:
name: create/prometheus
vars:
component_ns: "{{ org.name }}-bes"
external_url: "{{ org.external_url_suffix }}"
kubeconfig_path: "{{ org.k8s.config_file }}"
kube_context: "{{ org.k8s.context }}"
vault: "{{ org.vault }}"
gitops: "{{ org.gitops }}"
charts_dir: "platforms/shared/charts"
values_dir: "{{ playbook_dir }}/../../../{{ org.gitops.release_dir }}"
release_dir: "{{ playbook_dir }}/../../../{{ org.gitops.release_dir }}"
name: "{{ org.name | lower }}"
peers: "{{ org.services.peers }}"
org_url: "{{org.external_url_suffix}}"
component_name: "{{org.name | lower}}-bes"
component_type: "{{org.type | lower}}"
prometheus_port: "{{ org.prometheus.port }}"
prometheus_enabled: "{{ org.prometheus.enabled }}"
loop: "{{ network['organizations'] }}"
loop_control:
loop_var: org
when:
- org.prometheus.enabled == true

vars: #These variables can be overriden from the command line
install_os: "linux" #Default to linux OS
install_arch: "amd64" #Default to amd64 architecture
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
##############################################################################################
# Copyright Accenture. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
##############################################################################################

# Fetching the prometheus URLs
- name: Fetching the prometheus URLs
include_tasks: nested_loop.yaml
vars:
service: "{{ org.services.peers is defined | ternary(org.services.peers, org.services.validators) }}"
members: "{{service}}"

#Adding the prometheus chart repo
- name: Add stable chart repo
kubernetes.core.helm_repository:
name: stable
repo_url: "https://prometheus-community.github.io/helm-charts"

# Install prometheus via helmchart
- name: Deploy latest version of Prometheus chart
kubernetes.core.helm:
kubeconfig: "{{ kubeconfig_path }}"
name: "{{ name }}-prom"
chart_ref: stable/prometheus
release_namespace: "{{ component_ns }}"
create_namespace: true
values_files:
- "{{ playbook_dir }}/../../../platforms/hyperledger-besu/configuration/build/{{name}}-prometheus.yaml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- name: extracting data
set_fact:
targets: []

#Extracting the prometheus targets
- name: extracting the prometheus targets
vars:
prom_url: "{{node.name}}.{{component_name}}:{{node.metrics.port}}"
set_fact:
targets: "{{ targets + [prom_url] }}"
loop: "{{ members }}"
loop_control:
loop_var: node
when: node.metrics.enabled == true

#Updating the helm values
- name: Updating helm values config
template:
src={{ playbook_dir }}/../../../platforms/hyperledger-besu/configuration/roles/create/prometheus/templates/prometheus_release.j2
dest={{ playbook_dir }}/../../../platforms/hyperledger-besu/configuration/build/{{name}}-prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
extraScrapeConfigs: |
- job_name: besu
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
static_configs:
- targets: {{targets}}
alertmanager:
enabled: false
kube-state-metrics:
enabled: false
prometheus-node-exporter:
enabled: false
prometheus-pushgateway:
enabled: false
server:
service:
annotations:
{% if prometheus_enabled == 'true' %}
getambassador.io/config: |
---
apiVersion: ambassador/v2
kind: TCPMapping
port: {{prometheus_port}}
name: {{component_name}}
service: {{name}}-prom-prometheus-server.{{component_ns}}:80
{% endif %}

0 comments on commit 19125c3

Please sign in to comment.