示例#1
0
        public MetricsDeclarationBuilder WithStorageQueueMetric(string metricName                 = "promitor",
                                                                string metricDescription          = "Description for a metric",
                                                                string queueName                  = "promitor-queue",
                                                                string accountName                = "promitor-account",
                                                                string sasToken                   = "?sig=promitor",
                                                                string azureMetricName            = AzureStorageConstants.Queues.Metrics.MessageCount,
                                                                string resourceDiscoveryGroupName = "",
                                                                bool omitResource                 = false)
        {
            var secret = new SecretV1
            {
                RawValue = sasToken
            };

            var resource = new StorageQueueResourceV1
            {
                QueueName   = queueName,
                AccountName = accountName,
                SasToken    = secret
            };

            CreateAndAddMetricDefinition(ResourceType.StorageQueue, metricName, metricDescription, resourceDiscoveryGroupName, omitResource, azureMetricName, resource);

            return(this);
        }
示例#2
0
        public MetricsDeclarationBuilder WithAzureStorageQueueMetric(string metricName = "promitor", string metricDescription = "Description for a metric", string queueName = "promitor-queue", string accountName = "promitor-account", string sasToken = "?sig=promitor", string azureMetricName = AzureStorageConstants.Queues.Metrics.MessageCount)
        {
            var azureMetricConfiguration = CreateAzureMetricConfiguration(azureMetricName);
            var secret = new SecretV1
            {
                RawValue = sasToken
            };

            var resource = new StorageQueueResourceV1
            {
                QueueName   = queueName,
                AccountName = accountName,
                SasToken    = secret
            };

            var metric = new MetricDefinitionV1
            {
                Name        = metricName,
                Description = metricDescription,
                AzureMetricConfiguration = azureMetricConfiguration,
                Resources = new List <AzureResourceDefinitionV1> {
                    resource
                },
                ResourceType = ResourceType.StorageQueue
            };

            _metrics.Add(metric);

            return(this);
        }
        protected override StorageAccountResourceV1 DeserializeResource(YamlMappingNode node)
        {
            var storageAccountResource = base.DeserializeResource(node);

            var queueName = node.GetString(QueueNameTag);
            var sasToken  = node.DeserializeChild(SasTokenTag, _secretDeserializer);

            var storageQueueResource = new StorageQueueResourceV1(storageAccountResource)
            {
                QueueName = queueName,
                SasToken  = sasToken
            };

            return(storageQueueResource);
        }