From af4d61fa7ae3a638f2ce42a42251ad4b52cb45b1 Mon Sep 17 00:00:00 2001
From: mavinash <mavinash@newrelic.com>
Date: Wed, 4 Dec 2024 14:05:55 +0530
Subject: [PATCH 1/6] feat: Add Golden and Summary metrics for Media Streaming

---
 .../media_streaming-video/golden_metrics.yml  | 61 +++++++++++++++++++
 .../media_streaming-video/summary_metrics.yml | 40 ++++++++++++
 2 files changed, 101 insertions(+)
 create mode 100644 entity-types/media_streaming-video/golden_metrics.yml
 create mode 100644 entity-types/media_streaming-video/summary_metrics.yml

diff --git a/entity-types/media_streaming-video/golden_metrics.yml b/entity-types/media_streaming-video/golden_metrics.yml
new file mode 100644
index 000000000..d10fce48f
--- /dev/null
+++ b/entity-types/media_streaming-video/golden_metrics.yml
@@ -0,0 +1,61 @@
+rebufferingRatio:
+  title: Video Rebuffering Ratio (%)
+  unit: PERCENTAGE
+  query:
+    select : sum(timeSinceBufferBegin) / sum(timeSinceLastHeartbeat) - filter(sum(timeSincePaused), where actionName = 'CONTENT_RESUME' - filter(sum(timeSinceSeekBegin), where actionName = 'CONTENT_SEEK_END')) * 100
+    from: VideoAction
+adRebufferingRatio:
+  title: Ad Rebuffering Ratio (%)
+  unit: PERCENTAGE
+  query:
+    select: sum(timeSinceAdBufferBegin) / sum(timeSinceLastAdHeartbeat) - filter(sum(timeSinceAdPaused), where actionName = 'AD_RESUME' - filter(sum(timeSinceAdSeekBegin), where actionName = 'AD_SEEK_END')) * 100
+    from: VideoAdAction    
+averageBitrate:
+  title: Average Bitrate
+  unit: BITS_PER_SECOND
+  query:
+    select: average(contentBitrate)
+    from: VideoAction
+adAverageBitrate:
+  title: Ad Average Bitrate
+  unit: BITS_PER_SECOND
+  query:
+    select: average(adBitrate)
+    from: VideoAdAction
+averageStartTimeS:
+  title: Average Start Time (s)
+  unit: SECONDS
+  query:
+    select: average(timeSinceRequested)
+    from: VideoAction
+    where: actionName = 'CONTENT_START'
+adAverageStartTimeS:
+  title: Ad Average Start Time (s)
+  unit: SECONDS
+  query:
+    select: average(timeSinceAdRequested)
+    from: VideoAdAction
+videoStartFailures:
+  title: Video Start Failures
+  unit: PERCENTAGE
+  query:
+    select:  count(*) WHERE actionName = 'CONENT_ERROR' and contentPlayhead = 0 / (FROM VideoAction SELECT count(*) WHERE actionName = 'CONENT_START' and contentPlayhead=0) * 100
+    from: VideoErrorAction
+adStartFailures:
+  title: Ad Start Failures
+  unit: PERCENTAGE
+  query:
+    select: count(*) WHERE actionName = 'AD_ERROR' and adPlayhead = 0 / (FROM VideoAdAction SELECT count(*) WHERE actionName = 'AD_START' and adPlayhead = 0) * 100
+    from: VideoErrorAction     
+videoPlaybackFailures:
+  title: Video Playback Failures
+  unit: PERCENTAGE
+  query:
+    select: count(*) WHERE actionName = 'CONTENT_ERROR' and contentPlayhead > 0 / (FROM VideoAction SELECT count(*) WHERE actionName = 'CONENT_REQUEST') * 100
+    from: VideoErrorAction
+adPlaybackFailures:
+  title: Ad Playback Failures
+  unit: PERCENTAGE
+  query:
+    select: count(*) WHERE actionName = 'AD_ERROR' and adPlayhead > 0 / (FROM VideoAdAction SELECT count(*) WHERE actionName = 'AD_REQUEST') * 100
+    from: VideoErrorAction    
\ No newline at end of file
diff --git a/entity-types/media_streaming-video/summary_metrics.yml b/entity-types/media_streaming-video/summary_metrics.yml
new file mode 100644
index 000000000..281b09cfd
--- /dev/null
+++ b/entity-types/media_streaming-video/summary_metrics.yml
@@ -0,0 +1,40 @@
+rebufferingRatio:
+  goldenMetric: rebufferingRatio
+  unit: PERCENTAGE
+  title: Video Rebuffering Ratio (%)
+adRebufferingRation:
+  goldenMetric: adRebufferingRatio
+  unit: PERCENTAGE
+  title: Ad Rebuffering Ratio (%)
+averageBitrateMbps:
+  goldenMetric: averageBitrateMbps
+  unit: BITS_PER_SECOND
+  title: Average Bitrate (Mbps)
+adAverageBitrateMbps:
+  goldenMetric: adAverageBitrateMbps
+  unit: BITS_PER_SECOND
+  title: Ad Average Bitrate (Mbps)
+averageStartTimeS:
+  goldenMetric: averageStartTimeS
+  unit: SECONDS
+  title: Average Start Time (s)
+adAverageStartTimeS:
+  goldenMetric: adAverageStartTimeS
+  unit: SECONDS
+  title: Ad Average Start Time (s)
+videoStartFailures:
+  goldenMetric: videoStartFailures
+  unit: PERCENTAGE
+  title: Video Start Failures
+adStartFailures:
+  goldenMetric: adStartFailures
+  unit: PERCENTAGE
+  title: Ad Start Failures
+videoPlaybackFailures:
+  goldenMetric: videoPlaybackFailures
+  unit: PERCENTAGE
+  title: Video Playback Failures
+adPlaybackFailures:
+  goldenMetric: adPlaybackFailures
+  unit: PERCENTAGE
+  title: Ad Playback Failures   
\ No newline at end of file

From ae77ce78858fbf59c67c3914fff774530b53042c Mon Sep 17 00:00:00 2001
From: mavinash <mavinash@newrelic.com>
Date: Tue, 7 Jan 2025 16:36:43 +0530
Subject: [PATCH 2/6] feat: Add Summary and Golden Metrics

---
 .../media_streaming-video/golden_metrics.yml  | 30 +++++++++----------
 .../media_streaming-video/summary_metrics.yml | 18 +++++------
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/entity-types/media_streaming-video/golden_metrics.yml b/entity-types/media_streaming-video/golden_metrics.yml
index d10fce48f..ee8e7fa32 100644
--- a/entity-types/media_streaming-video/golden_metrics.yml
+++ b/entity-types/media_streaming-video/golden_metrics.yml
@@ -2,25 +2,25 @@ rebufferingRatio:
   title: Video Rebuffering Ratio (%)
   unit: PERCENTAGE
   query:
-    select : sum(timeSinceBufferBegin) / sum(timeSinceLastHeartbeat) - filter(sum(timeSincePaused), where actionName = 'CONTENT_RESUME' - filter(sum(timeSinceSeekBegin), where actionName = 'CONTENT_SEEK_END')) * 100
+    select: (sum(timeSinceBufferBegin)*100) / (sum(timeSinceLastHeartbeat) - filter(sum(timeSincePaused), where actionName = 'CONTENT_RESUME') - filter(sum(timeSinceSeekBegin), where actionName = 'CONTENT_SEEK_END'))
     from: VideoAction
 adRebufferingRatio:
   title: Ad Rebuffering Ratio (%)
   unit: PERCENTAGE
   query:
-    select: sum(timeSinceAdBufferBegin) / sum(timeSinceLastAdHeartbeat) - filter(sum(timeSinceAdPaused), where actionName = 'AD_RESUME' - filter(sum(timeSinceAdSeekBegin), where actionName = 'AD_SEEK_END')) * 100
-    from: VideoAdAction    
+    select: (sum(timeSinceAdBufferBegin)*100) / (sum(timeSinceLastAdHeartbeat) - filter(sum(timeSinceAdPaused), where actionName = 'AD_RESUME') - filter(sum(timeSinceAdSeekBegin), where actionName = 'AD_SEEK_END'))
+    from: VideoAdAction
 averageBitrate:
-  title: Average Bitrate
-  unit: BITS_PER_SECOND
+  title: Average Bitrate (B/s)
+  unit: BYTES_PER_SECOND
   query:
-    select: average(contentBitrate)
+    select: average(contentBitrate / 16) + average(contentRenditionBitrate / 16)
     from: VideoAction
 adAverageBitrate:
-  title: Ad Average Bitrate
-  unit: BITS_PER_SECOND
+  title: Ad Average Bitrate (B/s)
+  unit: BYTES_PER_SECOND
   query:
-    select: average(adBitrate)
+    select: average(adBitrate / 16) +
     from: VideoAdAction
 averageStartTimeS:
   title: Average Start Time (s)
@@ -39,23 +39,23 @@ videoStartFailures:
   title: Video Start Failures
   unit: PERCENTAGE
   query:
-    select:  count(*) WHERE actionName = 'CONENT_ERROR' and contentPlayhead = 0 / (FROM VideoAction SELECT count(*) WHERE actionName = 'CONENT_START' and contentPlayhead=0) * 100
+    select: count(*) WHERE actionName = 'CONENT_ERROR' and contentPlayhead = 0  * 100 / (FROM VideoAction SELECT count(*) WHERE actionName = 'CONENT_START' and contentPlayhead=0)
     from: VideoErrorAction
 adStartFailures:
   title: Ad Start Failures
   unit: PERCENTAGE
   query:
-    select: count(*) WHERE actionName = 'AD_ERROR' and adPlayhead = 0 / (FROM VideoAdAction SELECT count(*) WHERE actionName = 'AD_START' and adPlayhead = 0) * 100
-    from: VideoErrorAction     
+    select: count(*) WHERE actionName = 'AD_ERROR' and adPlayhead = 0  * 100 / (FROM VideoAdAction SELECT count(*) WHERE actionName = 'AD_START' and adPlayhead = 0)
+    from: VideoErrorAction
 videoPlaybackFailures:
   title: Video Playback Failures
   unit: PERCENTAGE
   query:
-    select: count(*) WHERE actionName = 'CONTENT_ERROR' and contentPlayhead > 0 / (FROM VideoAction SELECT count(*) WHERE actionName = 'CONENT_REQUEST') * 100
+    select: count(*) WHERE actionName = 'CONTENT_ERROR' and contentPlayhead > 0 * 100 / (FROM VideoAction SELECT count(*) WHERE actionName = 'CONENT_REQUEST')
     from: VideoErrorAction
 adPlaybackFailures:
   title: Ad Playback Failures
   unit: PERCENTAGE
   query:
-    select: count(*) WHERE actionName = 'AD_ERROR' and adPlayhead > 0 / (FROM VideoAdAction SELECT count(*) WHERE actionName = 'AD_REQUEST') * 100
-    from: VideoErrorAction    
\ No newline at end of file
+    select: count(*) WHERE actionName = 'AD_ERROR' and adPlayhead > 0  * 100 / (FROM VideoAdAction SELECT count(*) WHERE actionName = 'AD_REQUEST')
+    from: VideoErrorAction
diff --git a/entity-types/media_streaming-video/summary_metrics.yml b/entity-types/media_streaming-video/summary_metrics.yml
index 281b09cfd..bc85a9ce9 100644
--- a/entity-types/media_streaming-video/summary_metrics.yml
+++ b/entity-types/media_streaming-video/summary_metrics.yml
@@ -6,14 +6,14 @@ adRebufferingRation:
   goldenMetric: adRebufferingRatio
   unit: PERCENTAGE
   title: Ad Rebuffering Ratio (%)
-averageBitrateMbps:
-  goldenMetric: averageBitrateMbps
-  unit: BITS_PER_SECOND
-  title: Average Bitrate (Mbps)
-adAverageBitrateMbps:
-  goldenMetric: adAverageBitrateMbps
-  unit: BITS_PER_SECOND
-  title: Ad Average Bitrate (Mbps)
+averageBitrate:
+  goldenMetric: averageBitrate
+  unit: BYTES_PER_SECOND
+  title: Average Bitrate (B/s)
+adAverageBitrate:
+  goldenMetric: adAverageBitrate
+  unit: BYTES_PER_SECOND
+  title: Ad Average Bitrate (B/s)
 averageStartTimeS:
   goldenMetric: averageStartTimeS
   unit: SECONDS
@@ -37,4 +37,4 @@ videoPlaybackFailures:
 adPlaybackFailures:
   goldenMetric: adPlaybackFailures
   unit: PERCENTAGE
-  title: Ad Playback Failures   
\ No newline at end of file
+  title: Ad Playback Failures

From 6b16e43195d333812809c3adaa52c4624c742dd3 Mon Sep 17 00:00:00 2001
From: mavinash <mavinash@newrelic.com>
Date: Tue, 7 Jan 2025 16:54:24 +0530
Subject: [PATCH 3/6] fix: Queries

---
 entity-types/media_streaming-video/golden_metrics.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/entity-types/media_streaming-video/golden_metrics.yml b/entity-types/media_streaming-video/golden_metrics.yml
index ee8e7fa32..c52ae3441 100644
--- a/entity-types/media_streaming-video/golden_metrics.yml
+++ b/entity-types/media_streaming-video/golden_metrics.yml
@@ -20,7 +20,7 @@ adAverageBitrate:
   title: Ad Average Bitrate (B/s)
   unit: BYTES_PER_SECOND
   query:
-    select: average(adBitrate / 16) +
+    select: average(adBitrate / 16)
     from: VideoAdAction
 averageStartTimeS:
   title: Average Start Time (s)
@@ -39,13 +39,13 @@ videoStartFailures:
   title: Video Start Failures
   unit: PERCENTAGE
   query:
-    select: count(*) WHERE actionName = 'CONENT_ERROR' and contentPlayhead = 0  * 100 / (FROM VideoAction SELECT count(*) WHERE actionName = 'CONENT_START' and contentPlayhead=0)
+    select: (filter(count(*), WHERE actionName = 'CONENT_ERROR' and contentPlayhead = 0) * 100) / (FROM VideoAction SELECT count(*) WHERE actionName = 'CONENT_START' and contentPlayhead=0)
     from: VideoErrorAction
 adStartFailures:
   title: Ad Start Failures
   unit: PERCENTAGE
   query:
-    select: count(*) WHERE actionName = 'AD_ERROR' and adPlayhead = 0  * 100 / (FROM VideoAdAction SELECT count(*) WHERE actionName = 'AD_START' and adPlayhead = 0)
+    select: (filter(count(*) WHERE actionName = 'AD_ERROR' and adPlayhead = 0 ) * 100) / (FROM VideoAdAction SELECT count(*) WHERE actionName = 'AD_START' and adPlayhead = 0)
     from: VideoErrorAction
 videoPlaybackFailures:
   title: Video Playback Failures

From c8957d7b925fa8687738d3af616c3a51d3f188d5 Mon Sep 17 00:00:00 2001
From: mavinash <mavinash@newrelic.com>
Date: Tue, 7 Jan 2025 17:10:18 +0530
Subject: [PATCH 4/6] fix: Query syntax

---
 entity-types/media_streaming-video/golden_metrics.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/entity-types/media_streaming-video/golden_metrics.yml b/entity-types/media_streaming-video/golden_metrics.yml
index c52ae3441..ab24b4709 100644
--- a/entity-types/media_streaming-video/golden_metrics.yml
+++ b/entity-types/media_streaming-video/golden_metrics.yml
@@ -45,17 +45,17 @@ adStartFailures:
   title: Ad Start Failures
   unit: PERCENTAGE
   query:
-    select: (filter(count(*) WHERE actionName = 'AD_ERROR' and adPlayhead = 0 ) * 100) / (FROM VideoAdAction SELECT count(*) WHERE actionName = 'AD_START' and adPlayhead = 0)
+    select: (filter(count(*), WHERE actionName = 'AD_ERROR' and adPlayhead = 0 ) * 100) / (FROM VideoAdAction SELECT count(*) WHERE actionName = 'AD_START' and adPlayhead = 0)
     from: VideoErrorAction
 videoPlaybackFailures:
   title: Video Playback Failures
   unit: PERCENTAGE
   query:
-    select: count(*) WHERE actionName = 'CONTENT_ERROR' and contentPlayhead > 0 * 100 / (FROM VideoAction SELECT count(*) WHERE actionName = 'CONENT_REQUEST')
+    select: count(*) * 100 / (FROM VideoAction SELECT count(*) WHERE actionName = 'CONENT_REQUEST') WHERE actionName = 'CONTENT_ERROR' and contentPlayhead > 0
     from: VideoErrorAction
 adPlaybackFailures:
   title: Ad Playback Failures
   unit: PERCENTAGE
   query:
-    select: count(*) WHERE actionName = 'AD_ERROR' and adPlayhead > 0  * 100 / (FROM VideoAdAction SELECT count(*) WHERE actionName = 'AD_REQUEST')
+    select: count(*) * 100 / (FROM VideoAdAction SELECT count(*) WHERE actionName = 'AD_REQUEST') WHERE actionName = 'AD_ERROR' and adPlayhead > 0
     from: VideoErrorAction

From f75f1d78a76592d8106669cba86b7aaf99e715f2 Mon Sep 17 00:00:00 2001
From: mavinash <mavinash@newrelic.com>
Date: Tue, 7 Jan 2025 17:15:21 +0530
Subject: [PATCH 5/6] fix: Query for playback failures

---
 entity-types/media_streaming-video/golden_metrics.yml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/entity-types/media_streaming-video/golden_metrics.yml b/entity-types/media_streaming-video/golden_metrics.yml
index ab24b4709..2b578626c 100644
--- a/entity-types/media_streaming-video/golden_metrics.yml
+++ b/entity-types/media_streaming-video/golden_metrics.yml
@@ -51,11 +51,11 @@ videoPlaybackFailures:
   title: Video Playback Failures
   unit: PERCENTAGE
   query:
-    select: count(*) * 100 / (FROM VideoAction SELECT count(*) WHERE actionName = 'CONENT_REQUEST') WHERE actionName = 'CONTENT_ERROR' and contentPlayhead > 0
-    from: VideoErrorAction
+    select: count(*) * 100 / (FROM VideoAction SELECT count(*) WHERE actionName = 'CONENT_REQUEST')
+    from: VideoErrorAction WHERE actionName = 'CONTENT_ERROR' and contentPlayhead > 0
 adPlaybackFailures:
   title: Ad Playback Failures
   unit: PERCENTAGE
   query:
-    select: count(*) * 100 / (FROM VideoAdAction SELECT count(*) WHERE actionName = 'AD_REQUEST') WHERE actionName = 'AD_ERROR' and adPlayhead > 0
-    from: VideoErrorAction
+    select: count(*) * 100 / (FROM VideoAdAction SELECT count(*) WHERE actionName = 'AD_REQUEST')
+    from: VideoErrorAction WHERE actionName = 'AD_ERROR' and adPlayhead > 0

From 5f640ee75c5ef138521d0457fbdc2f308e951525 Mon Sep 17 00:00:00 2001
From: mavinash <mavinash@newrelic.com>
Date: Mon, 20 Jan 2025 14:41:59 +0530
Subject: [PATCH 6/6] fix: Add team in goldenTags

---
 entity-types/media_streaming-video/definition.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/entity-types/media_streaming-video/definition.yml b/entity-types/media_streaming-video/definition.yml
index 124ef6ba4..a8246a035 100644
--- a/entity-types/media_streaming-video/definition.yml
+++ b/entity-types/media_streaming-video/definition.yml
@@ -23,6 +23,7 @@ goldenTags:
   - deviceGroup
   - deviceManufacturer
   - deviceModel
+  - Team
 configuration:
   alertable: true
   entityExpirationTime: EIGHT_DAYS