# Long process notification

**URL:** <https://discuss.elastic.co/t/long-process-notification/310638>\
**Category:** Kibana\
**Tags:** elastic-stack-alerting\
**Created:** [July 26, 2022, 12:33pm UTC](https://discuss.elastic.co/t/long-process-notification/310638 "2022-07-26T12:33:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![azv](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@azv](https://discuss.elastic.co/u/azv)\
**Post date:** [July 26, 2022, 12:33pm UTC](https://discuss.elastic.co/t/long-process-notification/310638/1 "2022-07-26T12:33:37Z")

</div>

Hi!

There are processes in a console application we log spans. How can I create an alert to get a notification if a process takes too long to complete?

I have the following example code.

```auto
        private static void Example(string label, int ms)
        {
            var trans = Agent.Tracer.StartTransaction(
                label,
                Elastic.Apm.Api.ApiConstants.TypeRequest);

            trans.CaptureSpan("Span", Elastic.Apm.Api.ApiConstants.ActionExec, () =>
            {
                Thread.Sleep(TimeSpan.FromMilliseconds(ms)); // do something
            });

            trans.End();
        }

```

The chart looks like this.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/1/314707d81620660b2bc3c6a458bd992d608bd182.png)

I want to catch a running process if it doesn't finish in 2 minutes or exceeds duration of 95 percent of executions by more than 2 times, for instance.

I appreciate if someone help me.

---

<div class="post-metadata">

**Author:** ![EricDavisX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ericdavisx/32/73456_2.png) [@EricDavisX](https://discuss.elastic.co/u/EricDavisX)\
**Post date:** [July 26, 2022, 1:25pm UTC](https://discuss.elastic.co/t/long-process-notification/310638/2 "2022-07-26T13:25:08Z")

</div>

Hello Alex, thanks for logging in to ask - let me see if I can help.

Are you familiar with Kibana Alerting? See the docs here:

> **[Alerting | Kibana Guide \[8.3\] | Elastic](https://www.elastic.co/guide/en/kibana/current/alerting-getting-started.html)**
>
> Kibana provides you with several options to share \*Discover\* saved searches, dashboards, \*Visualize Library\* visualizations, and \*Canvas\* workpads with others, or on a website.

The Alerting Rules can send you notifications based on different types of thresholds and evaluations from the data ingested into your cluster.

The nuance being the data must be written into Elasticsearch to query against it... If you are capturing the process duration time metric, you can query against that field in the index. Perhaps, you could use the Metric Threshold Alert? See docs below:

> **[Create a metrics threshold rule | Observability Guide \[8.3\] | Elastic](https://www.elastic.co/guide/en/observability/8.3/metrics-threshold-alert.html)**

Let us know if this doesn't meet your needs, please!

---

<div class="post-metadata">

**Author:** ![azv](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@azv](https://discuss.elastic.co/u/azv)\
**Post date:** [July 27, 2022, 1:01pm UTC](https://discuss.elastic.co/t/long-process-notification/310638/3 "2022-07-27T13:01:08Z")

</div>

Hello, thanks for fast response!

I checked the links you sent. There is general info.

I created the following alerts with an email connector: Latency anomaly and Latency threshold. Seems, these alerts aren't designed for my case. I also don't understand alerts with queries using field names. I'm not sure which field I should use in this case. Would be great to see examples.

Could you please provide how-to tips of creating an alert for a long process duration?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 24, 2022, 1:01pm UTC](https://discuss.elastic.co/t/long-process-notification/310638/4 "2022-08-24T13:01:15Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
