Skip to content

Commit

Permalink
Merge pull request #51 from mfactory-lab/develop
Browse files Browse the repository at this point in the history
repair tds stats
  • Loading branch information
Rossignolskier authored Feb 9, 2022
2 parents a4f3c2d + 3cf1943 commit 62a5680
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 11 deletions.
2 changes: 1 addition & 1 deletion roles/monitoring/files/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def measurement_from_fields(name, data, tags, config, legacy_tags=None):
measurement = {
"measurement": name,
"time": round(time.time() * 1000),
"monitoring_version": "3.0.3",
"monitoring_version": "3.1.0",
"cluster_environment": config.cluster_environment,
"fields": data,
"tags": tags
Expand Down
50 changes: 50 additions & 0 deletions roles/monitoring/files/measurement_tds_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import time
import solana_rpc as rpc
from common import debug
from common import ValidatorConfig
import statistics
import numpy as np
import tds_info as tds
from common import measurement_from_fields

def load_data(config: ValidatorConfig):
identity_account_pubkey = rpc.load_identity_account_pubkey(config)
default = []
tds_data = default
tds_data = tds.load_tds_info(config, identity_account_pubkey)

result = {
'identity_account_pubkey': identity_account_pubkey,
'tds_data': tds_data
}

debug(config, str(result))

return result

def calculate_influx_fields(data):
if data is None:
result = {"tds_info": 0}
else:
identity_account_pubkey = data['identity_account_pubkey']

result = data['tds_data']
return result

def calculate_output_data(config: ValidatorConfig):
data = load_data(config)

tags = {
"validator_identity_pubkey": data['identity_account_pubkey'],
"validator_name": config.validator_name,
"cluster_environment": config.cluster_environment
}


measurement = measurement_from_fields(
"tds_info",
calculate_influx_fields(data),
tags,
config
)
return measurement
12 changes: 6 additions & 6 deletions roles/monitoring/files/measurement_validator_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from common import ValidatorConfig
import statistics
import numpy as np
import tds_info as tds
# import tds_info as tds
from common import measurement_from_fields


Expand Down Expand Up @@ -252,7 +252,7 @@ def load_data(config: ValidatorConfig):
identity_account_balance_data = default
leader_schedule_data = default
block_production_data = default
tds_data = default
# tds_data = default

vote_account_balance_data = default
vote_accounts_data = default
Expand All @@ -262,7 +262,7 @@ def load_data(config: ValidatorConfig):
identity_account_balance_data = rpc.load_identity_account_balance(config, identity_account_pubkey)
leader_schedule_data = rpc.load_leader_schedule(config, identity_account_pubkey)
block_production_data = rpc.load_block_production(config, identity_account_pubkey)
tds_data = tds.load_tds_info(config, identity_account_pubkey)
# tds_data = tds.load_tds_info(config, identity_account_pubkey)

if vote_account_pubkey is not None:
vote_account_balance_data = rpc.load_vote_account_balance(config, vote_account_pubkey)
Expand All @@ -283,7 +283,7 @@ def load_data(config: ValidatorConfig):
'solana_version_data': solana_version_data,
'stakes_data': stakes_data,
'validators_data': validators_data,
'tds_data': tds_data,
# 'tds_data': tds_data,
'cpu_model': rpc.load_cpu_model(config)
}

Expand Down Expand Up @@ -321,8 +321,8 @@ def calculate_influx_fields(data):
result.update(get_current_stake_metric(data['stakes_data']))
result.update(get_validators_metric(data['validators_data'], identity_account_pubkey))
result.update(get_block_production_cli_metrics(data['load_block_production_cli'], identity_account_pubkey))
result.update(data['tds_data'])
# result.update({"cpu_model": data['cpu_model']})
# result.update(data['tds_data'])
result.update({"cpu_model": data['cpu_model']})

return result

Expand Down
5 changes: 5 additions & 0 deletions roles/monitoring/files/output_tds_measurements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from monitoring_config import config
from measurement_tds_info import calculate_output_data
from common import print_json

print_json(calculate_output_data(config))
4 changes: 1 addition & 3 deletions roles/monitoring/files/tds_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ def tds_rpc_call(config: ValidatorConfig, identity_account_pubkey: str):

try:
debug(config, address)

json_response = requests.post(address, timeout=3).json()

json_response = requests.get(address, timeout=5).json()
if 'data' not in json_response:
result = {}
else:
Expand Down
2 changes: 2 additions & 0 deletions roles/monitoring/tasks/install_monitoring_script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@
- "measurement_validator_info.py"
- "output_gossip.py"
- "output_validator_measurements.py"
- "output_tds_measurements.py"
- "output_validators_info.py"
- "output_validators.py"
- "request_utils.py"
- "solana_rpc.py"
- "tds_info.py"
- "measurement_tds_info.py"
- "validator_monitoring.py"
tags:
- monitoring.script
Expand Down
24 changes: 23 additions & 1 deletion roles/monitoring/templates/telegraf.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,29 @@

json_time_format = "unix_ms"

##OUPUTS
[[inputs.exec]]
commands = [
"sudo -i -u {{ solana_user }} {{ solana_home }}/monitoring/output_starter.sh output_tds_measurements"
]
interval = "10m"
timeout = "30s"
json_name_key = "measurement"
json_time_key = "time"
tag_keys = ["tags_validator_name",
"tags_validator_identity_pubkey",
"tags_validator_vote_pubkey",
"tags_cluster_environment",
"validator_id",
"validator_name"]

json_string_fields = [
"validator_identity_pubkey",
"cluster_environment"]

json_time_format = "unix_ms"


##OUTPUTS
[[outputs.influxdb]]
database = "{{ telegraf_database }}"
urls = [ "{{ telegraf_urls }}" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ ExecStart={{ env_path }}/solana-validator \
{% endif %}
{% if rpc_node %}
--no-voting \
--account-index program-id \
--account-index spl-token-mint \
--account-index spl-token-owner \
{% endif %}
--no-port-check \
--limit-ledger-size {{ limit_ledger_size }} \
Expand Down

0 comments on commit 62a5680

Please sign in to comment.