Ejemplo n.º 1
0
        /// <summary>
        /// 根据告警ID查询告警规则信息。
        /// </summary>
        /// <param name="cesV1Client"></param>
        private static void ShowAlarmByID(CesClient cesClient)
        {
            ShowAlarmRequest showAlarmRequest = new ShowAlarmRequest()
            {
                AlarmId = "al1587000139213PNj4Pw2dZ"
            };

            try
            {
                ShowAlarmResponse showAlarmResponse = cesClient.ShowAlarm(showAlarmRequest);
                foreach (var metricAlarm in showAlarmResponse.MetricAlarms)
                {
                    Console.WriteLine("alarm_id: {0}, alarm_name: {1}", metricAlarm.AlarmId, metricAlarm.AlarmName);
                }
            }
            catch (RequestTimeoutException requestTimeoutException)
            {
                Console.WriteLine(requestTimeoutException.ErrorMessage);
            }
            catch (ServiceResponseException clientRequestException)
            {
                Console.WriteLine(clientRequestException.HttpStatusCode);
                Console.WriteLine(clientRequestException.ErrorCode);
                Console.WriteLine(clientRequestException.ErrorMsg);
            }
            catch (ConnectionException connectionException)
            {
                Console.WriteLine(connectionException.ErrorMessage);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 查询单条告警规则信息
        /// </summary>
        public async Task <ShowAlarmResponse> ShowAlarmAsync(ShowAlarmRequest showAlarmRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("alarm_id", showAlarmRequest.AlarmId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/V1.0/{project_id}/alarms/{alarm_id}", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, showAlarmRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("GET", request);

            return(JsonUtils.DeSerialize <ShowAlarmResponse>(response));
        }