/*! Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one or more contributor license agreements. * Licensed under the Elastic License 2.0; you may not use this file except in compliance with the Elastic License 2.0. */ (window.infra_bundle_jsonpfunction=window.infra_bundle_jsonpfunction||[]).push([[21],{545:function(e,t,a){"use strict";a.r(t);var r=a(37),i=a.n(r),n=a(2),l=a.n(n),o=a(35),s=a(1),c=a(51),u=a(78),m=a(103),d=a(11),E=a(17),g=a.n(E),h=a(243),p=a(21),x=a(313);t.default=({rule:e})=>{const{http:t,notifications:a}=Object(p.b)().services,r=e.params.criteria[0],n={from:"now-30d",to:"now"},E={gte:g.a.parse(n.from).valueOf(),lte:g.a.parse(n.to,{roundUp:!0}).valueOf()},{data:{histogramTriggeredAlerts:f,avgTimeToRecoverUS:y,totalTriggeredAlerts:T},isLoading:w,isError:z}=Object(h.d)({http:t,featureIds:[d.ib.LOGS],ruleId:e.id,dateRange:n});z&&(null==a||a.toasts.addDanger({title:s.i18n.translate("xpack.infra.alertDetails.logsAlertHistoryChart.error.toastTitle",{defaultMessage:"Logs alerts history chart error"}),text:s.i18n.translate("xpack.infra.alertDetails.logsAlertHistoryChart.error.toastDescription",{defaultMessage:"An error occurred when fetching logs alert history chart data"})}));const k=(null==f?void 0:f.filter((e=>e.doc_count>0)).map((e=>({dataValue:e.key,header:String(e.doc_count),details:i()(e.key_as_string).format("yyyy-MM-DD")}))))||[];return l.a.createElement(o.EuiPanel,{hasBorder:!0,"data-test-subj":"logsHistoryChartAlertDetails"},l.a.createElement(o.EuiFlexGroup,{direction:"column",gutterSize:"none",responsive:!1},l.a.createElement(o.EuiFlexItem,{grow:!1},l.a.createElement(o.EuiTitle,{size:"xs"},l.a.createElement("h2",null,s.i18n.translate("xpack.infra.logs.alertDetails.chartHistory.chartTitle",{defaultMessage:"Logs threshold alerts history"})))),l.a.createElement(o.EuiFlexItem,{grow:!1},l.a.createElement(o.EuiText,{size:"s",color:"subdued"},s.i18n.translate("xpack.infra.logs.alertDetails.chartHistory.last30days",{defaultMessage:"Last 30 days"})))),l.a.createElement(o.EuiSpacer,{size:"s"}),l.a.createElement(o.EuiFlexGroup,{gutterSize:"l"},l.a.createElement(o.EuiFlexItem,{grow:!1},l.a.createElement(o.EuiFlexGroup,{gutterSize:"xs",direction:"column"},l.a.createElement(o.EuiFlexItem,{grow:!1},l.a.createElement(o.EuiText,{color:"danger"},l.a.createElement(o.EuiTitle,{size:"s"},l.a.createElement("h3",null,w?l.a.createElement(o.EuiLoadingSpinner,{size:"s"}):T||"-")))),l.a.createElement(o.EuiFlexItem,{grow:!1},l.a.createElement(o.EuiText,{size:"s",color:"subdued"},s.i18n.translate("xpack.infra.logs.alertDetails.chartHistory.alertsTriggered",{defaultMessage:"Alerts triggered"}))))),l.a.createElement(o.EuiFlexGroup,{gutterSize:"xs",direction:"column"},l.a.createElement(o.EuiFlexItem,{grow:!1},l.a.createElement(o.EuiText,null,l.a.createElement(o.EuiTitle,{size:"s"},l.a.createElement("h3",null,w?l.a.createElement(o.EuiLoadingSpinner,{size:"s"}):y?Object(c.convertTo)({unit:"minutes",microseconds:y,extended:!0}).formatted:"-")))),l.a.createElement(o.EuiFlexItem,{grow:!1},l.a.createElement(o.EuiText,{size:"s",color:"subdued"},s.i18n.translate("xpack.infra.logs.alertDetails.chartHistory.avgTimeToRecover",{defaultMessage:"Avg time to recover"}))))),l.a.createElement(o.EuiSpacer,{size:"s"}),l.a.createElement(x.a,{annotations:[l.a.createElement(u.LineAnnotation,{id:"annotations",key:"annotationsAlertHistory",domainType:u.AnnotationDomainType.XDomain,dataValues:k,style:{line:{strokeWidth:3,stroke:m.euiThemeVars.euiColorDangerText,opacity:1}},marker:l.a.createElement(o.EuiIcon,{type:"warning",color:"danger"}),markerBody:e=>l.a.createElement(l.a.Fragment,null,l.a.createElement(o.EuiBadge,{color:"danger"},l.a.createElement(o.EuiText,{size:"xs",color:"white"},e.header)),l.a.createElement(o.EuiSpacer,{size:"xs"})),markerPosition:u.Position.Top})],ruleParams:e.params,logViewReference:e.params.logView,chartCriterion:r,showThreshold:!0,executionTimeRange:E}))}}}]);