Esempio n. 1
0
        public static void ReportingApplicationMetrics(ApplicationMetricsDataStore appDS)
        {
            String json = JsonConvert.SerializeObject(appDS);

            Byte[] bytes = new ASCIIEncoding().GetBytes(json);

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri("http://localhost:9200/metricsapp/_doc"));

            request.Method      = "POST";
            request.Accept      = "application/json";
            request.ContentType = "application/json";

            Stream newStream = request.GetRequestStream();

            newStream.Write(bytes, 0, bytes.Length);
            newStream.Close();

            HttpWebResponse response;

            try
            {
                response = (HttpWebResponse)request.GetResponse();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }


            //var stream = response.GetResponseStream();
            //var sr = new StreamReader(stream);
            //var content = sr.ReadToEnd();
        }
Esempio n. 2
0
        public ActionResult <string> GetErr(int id)
        {
            ApplicationMetricsDataStore ds = null;
            int i = ds.ActiveRequests;

            return("value");
        }
Esempio n. 3
0
        public static void ReportingAppMetrics(int intervalTime)
        => new Task(() =>
        {
            while (true)
            {
                ApplicationMetricsDataStore appDS = new ApplicationMetricsDataStore()
                {
                    Timestamp             = DateTime.Now,
                    ActiveRequests        = CounterMetrics._countActiveRequests,
                    Errors5xx             = CounterMetrics._countErrors5xx,
                    Errors4xx             = CounterMetrics._countErrors4xx,
                    CpuUsage              = GaugeMetrics.CpuUsage(),
                    PhysicalMemoryUsageMB = GaugeMetrics.MemoryUsage()
                };

                ElasticSearchReport.ReportingApplicationMetrics(appDS);

                Thread.Sleep(intervalTime);
            }
        }, TaskCreationOptions.LongRunning)
        .Start();