tb_pulumi.monitoring¶
Common code related to monitoring patterns.
- class tb_pulumi.monitoring.AlarmGroup(pulumi_type: str, name: str, monitoring_group: MonitoringGroup, project: ThunderbirdPulumiProject, resource: Resource, opts: ResourceOptions = None, tags: dict = {})¶
Bases:
ThunderbirdComponentResource
A collection of alarms set up to monitor a particular single resource. For example, there are multiple metrics to alarm on pertaining to a load balancer. An
AlarmGroup
would collect all of those alarms under one object. This class should be considered a base class for building more sophisticated alarm groups.- Parameters:
pulumi_type (str) – The “type” string (commonly referred to in docs as just
t
) of the component as described by Pulumi’s docs.name (str) – The name of the
AlarmGroup
resource.monitoring_group (MonitoringGroup) – The
MonitoringGroup
that thisAlarmGroup
belongs to. This is how configuration overrides are delivered from the YAML config file to the individual alarm groups.project (tb_pulumi.ThunderbirdPulumiProject) – The
ThunderbirdPulumiProject
whose resources are being monitored.resource (pulumi.Resource) – The Pulumi
Resource
object thisAlarmGroup
is building alarms for.opts (pulumi.ResourceOptions, optional) – Additional
pulumi.ResourceOptions
to apply to this resource. Defaults to None.tags (dict, optional) – Key/value pairs to merge with the default tags which get applied to all resources in this group. Defaults to {}.
- property overrides: dict¶
If the user has configured any overrides for alarms related to this resource, this function returns them.
- class tb_pulumi.monitoring.MonitoringGroup(pulumi_type: str, name: str, project: ThunderbirdPulumiProject, type_map: dict, config: dict = {}, opts: ResourceOptions = None, tags: dict = {})¶
Bases:
ProjectResourceGroup
A broad-scope approach to aggregate resource monitoring. A
MonitoringGroup
is a very thin class that should be extended to provide specific monitoring solutions for the resources contained in the specifiedproject
.- Parameters:
pulumi_type (str) – The “type” string (commonly referred to in docs as just
t
) of the component as described by Pulumi’s type docs.name (str) – The name of the
MonitoringGroup
resource.project (tb_pulumi.ThunderbirdPulumiProject) – The
ThunderbirdPulumiProject
to build monitoring resources for.type_map (dict[type, type]) – A dict where the keys are
pulumi.Resource
derivatives representing types of resources this monitoring group recognizes, and where the values aretb_pulumi.monitoring.AlarmGroup
derivatives which actually declare those monitors. For example, anaws.cloudfront.Distribution
key might map to atb_pulumi.cloudwatch.CloudFrontDistributionAlarmGroup
value.config (dict, optional) –
A configuration dictionary. The specific format and content of this dictionary is defined in part by classes extending this class. However, the dictionary should be configured in the following broad way, with downstream monitoring groups defining the specifics of the monitor configs (shown here as YAML):
1--- 2alarms: 3 name-of-the-resource-being-monitored: 4 monitor_name: 5 enabled: False 6 # Downstream monitoring groups tell you what else goes right here
This config defines override settings for alarms whose default configurations are insufficient for a specific use case. Since each resource can have multiple alarms associated with it, the
"alarm"
dict’s keys should be the names of Pulumi resources being monitored. Their values should also be dictionaries, and those keys should be the names of the alarms as defined in the documentation for those alarm groups.All alarms should respond to a boolean
"enabled"
value such that the alarm will not be created if this isFalse
. Beyond that, configure each alarm as described in its alarm group documentation. Defaults to {}.opts (pulumi.ResourceOptions, optional) – Additional
pulumi.ResourceOptions
to apply to this resource. Defaults to None.tags (dict, optional) – Key/value pairs to merge with the default tags which get applied to all resources in this group. Defaults to {}.
- abstractmethod classmethod monitor()¶
This function is called by
tb_pulumi.monitoring.MonitoringGroup.ready()
when theMonitoringGroup
has determined what resources are supported by this library. This class is downstream from atb_pulumi.ThunderbirdComponentResource
, and is an extension of itstb_pulumi.ThunderbirdComponentResource.__init__()
function, thefinish
call for downstream monitoring groups should be made from within this function instead of the constructor.Because this works as an extension of
__init__
, thefinish
call for downstream monitoring groups should be made from within this function instead of the constructor.
- ready(outputs: list[Resource])¶
This function is called by the
tb_pulumi.ProjectResourceGroup
after all outputs in the project have been resolved into values. Here, we examine those resources and determine which ones this library is capable of building alarms for. These become oursupported_resources
, which are to be accessed by classes implementing this one.- Parameters:
outputs (list[pulumi.Resource]) – A list of resolved outputs discovered in the project. This is provided primarily for reference, but has limited value.
- supported_resources¶
All resources in the project which have an entry in the type_map; this may contain Outputs, which will be resolved by the time
tb_pulumi.monitoring.MonitoringGroup.monitor()
is invoked.