Set a resource(type and labels) that can be used for monitoring.
    :param series: TimeSeries object based on view data
    :param option_resource_type: Resource is an optional field that
    represents the Stackdriver MonitoredResource type.

def set_monitored_resource(series, option_resource_type):
    """Set a resource(type and labels) that can be used for monitoring.
    :param series: TimeSeries object based on view data
    :param option_resource_type: Resource is an optional field that
    represents the Stackdriver MonitoredResource type.
    """
    resource_type = GLOBAL_RESOURCE_TYPE

    if option_resource_type == "":
        resource = monitored_resource.get_instance()
        if resource is not None:
            resource_labels = resource.get_labels()

            if resource.get_type() == 'gke_container':
                resource_type = 'k8s_container'
                set_attribute_label(series, resource_labels, 'project_id')
                set_attribute_label(series, resource_labels, 'cluster_name')
                set_attribute_label(series, resource_labels, 'container_name')
                set_attribute_label(series, resource_labels, 'namespace_id',
                                    'namespace_name')
                set_attribute_label(series, resource_labels, 'pod_id',
                                    'pod_name')
                set_attribute_label(series, resource_labels, 'zone',
                                    'location')

            elif resource.get_type() == 'gce_instance':
                resource_type = 'gce_instance'
                set_attribute_label(series, resource_labels, 'project_id')
                set_attribute_label(series, resource_labels, 'instance_id')
                set_attribute_label(series, resource_labels, 'zone')

            elif resource.get_type() == 'aws_ec2_instance':
                resource_type = 'aws_ec2_instance'
                set_attribute_label(series, resource_labels, 'aws_account')
                set_attribute_label(series, resource_labels, 'instance_id')
                set_attribute_label(series, resource_labels, 'region',
                                    label_value_prefix='aws:')
    else:
        resource_type = option_resource_type
    series.resource.type = resource_type