Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating network dashboard: fixing Cloud SQL problem, fixing 1 metric… #1806

Merged
merged 6 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"alignmentPeriod": "3600s",
"perSeriesAligner": "ALIGN_NEXT_OLDER"
},
"filter": "metric.type=\"custom.googleapis.com/netmon/network/forwarding_rules_l4_used_ratio\" resource.type=\"global\"",
"filter": "metric.type=\"custom.googleapis.com/netmon/network/forwarding_rules_l7_used_ratio\" resource.type=\"global\"",
"secondaryAggregation": {
"alignmentPeriod": "60s",
"perSeriesAligner": "ALIGN_MEAN"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module "pubsub" {
project_id = module.project.project_id
name = var.name
regions = [var.region]
subscriptions = { "${var.name}-default" = null }
subscriptions = {}
}
ludoo marked this conversation as resolved.
Show resolved Hide resolved

module "cloud-function" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ def start_discovery(resources, response=None, data=None):
LOGGER.info(f'discovery (has response: {response is not None})')
if response is None:
# return initial discovery URLs
if (not resources['config:folders'] and not resources['config:projects']):
aurelienlegrand marked this conversation as resolved.
Show resolved Hide resolved
LOGGER.info(
f'No monitored project or folder given, defaulting to discovery root: {resources["config:discovery_root"]}'
)
dr_node = resources["config:discovery_root"].split("/")[0]
dr_value = resources["config:discovery_root"].split("/")[1]
yield HTTPRequest(CAI_URL.format(f'{dr_node}/{dr_value}'), {}, None)
for v in resources['config:folders']:
yield HTTPRequest(CAI_URL.format(f'folders/{v}'), {}, None)
for v in resources['config:projects']:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,13 @@ def _handle_sql_instances(resource, data):
'name': data['name'],
'self_link': _self_link(data['selfLink']),
'ipAddresses': [
i['ipAddress'] for i in data['ipAddresses'] if i['type'] == 'PRIVATE'
i['ipAddress']
for i in data.get('ipAddresses')
if i['type'] == 'PRIVATE'
],
'region': data['region'],
'availabilityType': data['settings']['availabilityType'],
'network': data['settings']['ipConfiguration']['privateNetwork']
'network': data['settings']['ipConfiguration'].get('privateNetwork')
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import datetime
import json
import logging
import time

from . import HTTPRequest
from .utils import batched

DESCRIPTOR_TYPE_BASE = 'custom.googleapis.com/{}'
DESCRIPTOR_URL = ('https://content-monitoring.googleapis.com/v3'
Expand Down Expand Up @@ -74,6 +74,7 @@ def timeseries_requests(project_id, root, timeseries, descriptors):
bucket.append(ts)
LOGGER.info(f'metric types {list(ts_buckets.keys())}')
ts_buckets = list(ts_buckets.values())
api_calls = 0
while ts_buckets:
data = {'timeSeries': []}
for bucket in ts_buckets:
Expand Down Expand Up @@ -103,4 +104,10 @@ def timeseries_requests(project_id, root, timeseries, descriptors):
tot_num = sum(len(b) for b in ts_buckets)
LOGGER.info(f'sending {req_num} remaining: {tot_num}')
yield HTTPRequest(url, HEADERS, json.dumps(data))
api_calls += 1
# Default quota is 180 request per minute per user
if (api_calls > 170):
ludoo marked this conversation as resolved.
Show resolved Hide resolved
LOGGER.info(f'Pausing for 1 minute to avoid monitoring quota issues')
time.sleep(60)
api_calls = 0
ts_buckets = [b for b in ts_buckets if b]