-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdd_usage_pull.py
More file actions
1825 lines (1622 loc) · 94.7 KB
/
Copy pathdd_usage_pull.py
File metadata and controls
1825 lines (1622 loc) · 94.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
"""
dd_usage_pull.py — Datadog → Coralogix Usage Report
=====================================================
Pulls Datadog usage metrics from the official Usage Metering API, mirrors
every tile on the Bill Overview page, converts the numbers to Coralogix
sizing using the same formulas as the sizing Excel template, then packages
all outputs into a single ZIP file ready to hand off.
Usage
-----
python dd_usage_pull.py [--month YYYY-MM] [--site datadoghq.com] [--out DIR]
Environment variables (put these in a .env file next to the script):
DD_API_KEY Datadog API key (needs usage_read)
DD_APP_KEY Datadog Application key (needs usage_read)
DD_SITE datadoghq.com | datadoghq.eu | us3/us5.datadoghq.com (default: datadoghq.com)
DD_MONTH YYYY-MM (default: previous calendar month)
This script collects usage volumes only (logs, metrics, traces, RUM, synthetics).
It does NOT call Datadog cost or billing-dollar endpoints.
"""
from __future__ import annotations
import argparse
import csv
import io
import json
import os
import sys
import time
import zipfile
from dataclasses import dataclass, field, fields as dc_fields
from datetime import datetime, timezone, timedelta
from pathlib import Path
from typing import Any
# ── Dependency guards ──────────────────────────────────────────────────────
try:
import requests
except ImportError:
sys.exit("\n Missing 'requests'. Run: pip install requests\n")
try:
from dotenv import load_dotenv
except ImportError:
sys.exit("\n Missing 'python-dotenv'. Run: pip install python-dotenv\n")
try:
import openpyxl
from openpyxl.styles import Font, PatternFill, Alignment, Border, Side
from openpyxl.utils import get_column_letter
HAS_OPENPYXL = True
except ImportError:
HAS_OPENPYXL = False
print(" [warn] openpyxl not installed — Excel output will be skipped. Run: pip install openpyxl")
load_dotenv()
# ═══════════════════════════════════════════════════════════════════════════
# SECTION 1 — Constants (all sizing assumptions live here)
# ═══════════════════════════════════════════════════════════════════════════
AVG_LOG_SIZE_KB = 2.5 # assumed average compressed log line size
AVG_SPAN_SIZE_KB = 1.5 # assumed average span payload size
TS_PER_HOST = 750 # estimated Prometheus/DD time series per host or container
TS_TO_UNITS = 3.3e-5 # Coralogix metrics: TimeSeries → Units/day conversion
DAYS_PER_MONTH = 30.0 # used for all monthly → daily conversions
HOURS_PER_MONTH = 30.0 * 24 # 720 — Datadog _sum fields for hosts/containers are in host-hours
SW_LABEL_FACTOR = 0.30 # serverless TS = invocations × 3 labels × 10% unique = ×0.30
LOG_TIER_MON = 0.70 # Monitoring share of ingested logs
LOG_TIER_COMP = 0.30 # Compliance share
SPAN_TIER_MON = 0.10 # Monitoring share of ingested spans
SPAN_TIER_COMP = 0.90 # Compliance share of ingested spans
KNOWN_SITES: dict[str, str] = {
"datadoghq.com": "https://api.datadoghq.com",
"datadoghq.eu": "https://api.datadoghq.eu",
"us3.datadoghq.com": "https://api.us3.datadoghq.com",
"us5.datadoghq.com": "https://api.us5.datadoghq.com",
"ddog-gov.com": "https://api.ddog-gov.com",
}
FRESHNESS_NOTE = (
"Datadog usage data may be delayed up to 72 hours."
)
# ═══════════════════════════════════════════════════════════════════════════
# SECTION 2 — Datadog API client
# ═══════════════════════════════════════════════════════════════════════════
class DatadogClient:
"""Thin, retry-aware wrapper around Datadog's Usage Metering API."""
MAX_RETRIES = 4
RETRY_WAIT_S = 2 # exponential: 2, 4, 8 seconds
def __init__(self, api_key: str, app_key: str, site: str = "datadoghq.com"):
if site not in KNOWN_SITES:
sys.exit(
f"\n Unknown Datadog site: '{site}'\n"
f" Allowed values: {', '.join(KNOWN_SITES)}\n"
)
self.base_url = KNOWN_SITES[site]
self.headers = {
"Accept": "application/json",
"DD-API-KEY": api_key,
"DD-APPLICATION-KEY": app_key,
}
def _get(self, path: str, params: dict | None = None) -> dict:
url = f"{self.base_url}{path}"
for attempt in range(self.MAX_RETRIES):
try:
resp = requests.get(url, headers=self.headers, params=params or {}, timeout=45)
if resp.status_code == 429:
wait = self.RETRY_WAIT_S ** (attempt + 1)
print(f" Rate limited — waiting {wait}s (retry {attempt+1}/{self.MAX_RETRIES})")
time.sleep(wait)
continue
if resp.status_code == 403:
raise PermissionError(
f"403 Forbidden: {path}\n"
" Ensure the API and Application keys have usage_read."
)
if resp.status_code == 400:
raise ValueError(f"400 Bad Request: {path} — {resp.text[:300]}")
resp.raise_for_status()
return resp.json()
except (requests.ConnectionError, requests.Timeout) as exc:
if attempt == self.MAX_RETRIES - 1:
raise
wait = self.RETRY_WAIT_S ** (attempt + 1)
print(f" Network error ({exc}) — retrying in {wait}s")
time.sleep(wait)
raise RuntimeError(f"All retries exhausted for {path}")
# ── Individual endpoint wrappers ────────────────────────────────────────
def usage_summary(self, start_month: str, end_month: str | None = None) -> dict:
p: dict[str, str] = {"start_month": start_month}
if end_month:
p["end_month"] = end_month
return self._get("/api/v1/usage/summary", p)
# ═══════════════════════════════════════════════════════════════════════════
# SECTION 3 — Data model
# ═══════════════════════════════════════════════════════════════════════════
@dataclass
class UsageSnapshot:
"""All Datadog usage metrics for one calendar month."""
month: str = ""
account_name: str = ""
region: str = ""
site: str = ""
pulled_at: str = ""
# ── Infrastructure ──────────────────────────────────────────────────────
infra_hosts: float = 0 # Infra Hosts tile (concurrent count)
apm_hosts: float = 0 # APM Hosts tile (concurrent count)
containers: float = 0 # concurrent container count (for sizing formulas)
container_hours: float = 0 # Container Hours tile (total host-hours in month)
network_hosts: float = 0 # Network Hosts tile
dbm_hosts: float = 0 # DBM Hosts tile
# ── Profiling ───────────────────────────────────────────────────────────
profiled_hosts: float = 0
profiled_containers: float = 0
profiled_fargate: float = 0
apm_fargate: float = 0
fargate_tasks: float = 0
# ── Custom Metrics ──────────────────────────────────────────────────────
custom_metrics: float = 0 # Custom Metrics tile (time series)
ingested_custom_metrics: float = 0 # Ingested Custom Metrics tile
# ── Logs ────────────────────────────────────────────────────────────────
ingested_logs_bytes: float = 0 # Ingested Logs tile (bytes)
indexed_logs_3day: float = 0 # events
indexed_logs_7day: float = 0
indexed_logs_15day: float = 0
indexed_logs_30day: float = 0
indexed_logs_45day: float = 0
indexed_logs_60day: float = 0
indexed_logs_90day: float = 0
indexed_logs_180day: float = 0
indexed_logs_360day: float = 0
indexed_logs_live: float = 0 # live search (short-term)
indexed_logs_rehydrated: float = 0 # rehydrated from archive
security_logs_bytes: float = 0 # SIEM analyzed logs
# ── APM / Tracing ───────────────────────────────────────────────────────
ingested_spans_bytes: float = 0 # Ingested Spans tile (bytes)
indexed_spans: float = 0 # Indexed Spans tile (events)
custom_events: float = 0 # Custom Events tile
# ── Serverless ──────────────────────────────────────────────────────────
serverless_functions: float = 0 # Serverless Workload Functions tile
serverless_invocations: float = 0 # total invocations (monthly)
serverless_app_instances: float = 0 # Serverless App Instances tile
# ── RUM ─────────────────────────────────────────────────────────────────
rum_sessions: float = 0 # RUM Investigate tile
rum_lite_sessions: float = 0 # RUM Measure tile
rum_replay: float = 0 # Session Replay tile
rum_errors: float = 0 # Error Tracking Events
# ── Synthetics ──────────────────────────────────────────────────────────
synthetics_api: float = 0
synthetics_browser: float = 0
# ── Other ───────────────────────────────────────────────────────────────
incident_management_seats: float = 0
test_optimization_committers: float = 0
test_optimization_spans: float = 0
product_analytics_sessions: float = 0
session_replay: float = 0 # may alias rum_replay
app_builder_apps: float = 0
bits_ai_investigations: float = 0
# ── Full API responses for raw JSON export ───────────────────────────────
raw: dict = field(default_factory=dict)
@dataclass
class CoralogixSizing:
"""Coralogix sizing estimates derived from Datadog usage."""
# ── Logs ────────────────────────────────────────────────────────────────
total_ingested_logs_gb_month: float = 0
total_indexed_logs_count: float = 0 # events
indexed_logs_size_gb_month: float = 0
indexed_pct_logs: float = 0
daily_logs_gb: float = 0
daily_logs_fs_gb: float = 0 # unused, kept for compat
daily_logs_mon_gb: float = 0 # Monitoring (40 %)
daily_logs_comp_gb: float = 0 # Compliance (10 %)
# ── Metrics ─────────────────────────────────────────────────────────────
host_count: float = 0
container_count: float = 0
host_container_ts: float = 0
sw_func_ts: float = 0
sw_invoc_ts: float = 0
total_ts: float = 0
metrics_units_per_day: float = 0
# ── Tracing ─────────────────────────────────────────────────────────────
ingested_spans_gb_month: float = 0
indexed_spans_gb_month: float = 0
indexed_pct_spans: float = 0
daily_spans_ingest_gb: float = 0
daily_spans_mon_gb: float = 0
daily_spans_comp_gb: float = 0
daily_spans_indexed_gb: float = 0
daily_spans_archive_gb: float = 0
# ── RUM ─────────────────────────────────────────────────────────────────
rum_sessions_monthly: float = 0
rum_sessions_daily: float = 0
rum_session_recording_daily: float = 0
rum_errors_per_day: float = 0
# ── Synthetics → Checkly ────────────────────────────────────────────────
synthetics_api_daily: float = 0
synthetics_browser_daily: float = 0
synthetics_api_monthly: float = 0
synthetics_browser_monthly: float = 0
# ═══════════════════════════════════════════════════════════════════════════
# SECTION 4 — Extraction helpers
# ═══════════════════════════════════════════════════════════════════════════
def _f(item: dict, *keys: str) -> float:
"""Return the first non-None numeric value found among `keys`, else 0."""
for k in keys:
v = item.get(k)
if v is not None:
try:
return float(v)
except (TypeError, ValueError):
continue
return 0.0
def extract_usage_snapshot(
summary_raw: dict,
month: str,
site: str,
) -> UsageSnapshot:
"""Build a UsageSnapshot from all available API responses."""
snap = UsageSnapshot(
month=month,
site=site,
pulled_at=datetime.now(timezone.utc).isoformat(),
)
# ── Usage summary ────────────────────────────────────────────────────────
usage_list = summary_raw.get("usage", [])
if usage_list:
# Select the item whose date matches the target month, or use the last item.
item = usage_list[-1]
for u in usage_list:
date_str = str(u.get("date", u.get("start_date", "")))
if date_str.startswith(month):
item = u
break
# Account name: try top-level first, then orgs[0]
snap.account_name = item.get("account_name", item.get("org_name", ""))
if not snap.account_name:
orgs = item.get("orgs", [])
if orgs:
snap.account_name = orgs[0].get("account_name", orgs[0].get("org_name", ""))
snap.region = item.get("region", "")
# Infrastructure
# IMPORTANT: Datadog's v2 API uses "_sum" fields that represent TOTAL HOST-HOURS
# for the month (not a concurrent count). We divide by HOURS_PER_MONTH (720) to
# recover the average concurrent host count for sizing purposes.
# "top99p" fields are already a concurrent count (peak), so they're used as-is.
def _hosts_from_hours(hours_field: str, *top99p_fields: str) -> float:
"""Try top99p (count) first; fall back to hours ÷ 720."""
for k in top99p_fields:
v = _f(item, k)
if v: return v
h = _f(item, hours_field)
return h / HOURS_PER_MONTH if h else 0.0
# Sum all host types; prefer top99p counts, fall back to hours/720
snap.infra_hosts = (
_hosts_from_hours("agent_host_sum", "agent_host_top99p_sum", "agent_host_top99p")
+ _hosts_from_hours("aws_host_sum", "aws_host_top99p_sum", "aws_host_top99p")
+ _hosts_from_hours("azure_host_sum", "azure_host_top99p_sum", "azure_host_top99p")
+ _hosts_from_hours("gcp_host_sum", "gcp_host_top99p_sum", "gcp_host_top99p")
+ _hosts_from_hours("vsphere_host_sum", "vsphere_host_top99p_sum", "vsphere_host_top99p")
+ _hosts_from_hours("alibaba_host_sum", "alibaba_host_top99p_sum")
+ _hosts_from_hours("heroku_host_sum", "heroku_host_top99p_sum")
+ _hosts_from_hours("opentelemetry_host_sum", "opentelemetry_host_top99p_sum")
) or _hosts_from_hours("infra_hours_sum", "infra_host_top99p_sum", "infra_host_top99p")
snap.apm_hosts = _hosts_from_hours(
"apm_host_sum",
"apm_host_top99p_sum", "apm_host_top99p",
) or _hosts_from_hours("apm_host_incl_usm_sum", "apm_host_incl_usm_top99p")
snap.network_hosts = _f(item, "npm_host_top99p", "npm_host_top99p_sum") or \
_hosts_from_hours("npm_host_sum", "network_device_count_top99p_sum")
snap.dbm_hosts = _f(item, "dbm_host_top99p", "dbm_host_top99p_sum",
"dbm_host_database_instance_top99p")
# Containers: "_sum" = total container-hours for the month; ÷720 = concurrent count
raw_container_hours = _f(item, "container_sum", "container_count_avg_sum",
"container_avg_sum")
snap.container_hours = raw_container_hours # used for the "Container Hours" tile
snap.containers = (
_f(item, "container_count_avg", "container_avg") # already an average — use as-is
or (raw_container_hours / HOURS_PER_MONTH if raw_container_hours else 0.0)
)
# Profiling / Fargate
# profiling_host_top99p is already a concurrent count; profiling_container_agent_count_sum is hours
snap.profiled_hosts = _f(item,
"profiling_host_top99p",
"profiling_host_count_top99p_sum", "profiling_host_count_top99p",
"profiling_uncategorized_host_count_top99p",
)
_prof_cont_hours = _f(item, "profiling_container_agent_count_sum")
snap.profiled_containers = (
_f(item, "profiling_container_agent_count_avg", "profiling_container_count_avg_sum")
or (_prof_cont_hours / HOURS_PER_MONTH if _prof_cont_hours else 0.0)
)
snap.profiled_fargate = _f(item,
"avg_profiled_fargate_tasks",
"avg_profiled_fargate_tasks_hw_max_sum",
"profiling_aas_count_top99p_sum",
"fargate_container_profiler_profiling_fargate_avg",
)
snap.apm_fargate = _f(item, "apm_fargate_count_avg_sum", "apm_fargate_count_avg")
snap.fargate_tasks = _f(item, "fargate_tasks_count_avg_sum",
"fargate_tasks_count_avg", "fargate_tasks_count_hwm")
# Custom Metrics
snap.custom_metrics = _f(item, "custom_ts_avg", "custom_ts_avg_sum",
"custom_timeseries_avg_sum")
snap.ingested_custom_metrics = _f(item, "custom_ingested_timeseries_average_sum",
"ingested_custom_timeseries_average_sum",
"custom_live_ts_avg_sum", "custom_live_ts_avg")
# Logs — ingested bytes
# "live_ingested_bytes_sum" is the most common field in newer API responses
snap.ingested_logs_bytes = _f(item,
"live_ingested_bytes_sum", # ← most common in 2025+ responses
"ingested_events_bytes_sum",
"ingested_events_bytes_agg_sum",
"billable_ingested_bytes_agg_sum",
"logs_live_ingested_bytes_agg_sum",
)
# Indexed logs — Datadog uses two naming conventions for retention tiers:
# logs_indexed_logs_usage_sum_N_day (newer, e.g. 2025+)
# logs_indexed_Nday_agg_sum (older)
snap.indexed_logs_live = _f(item,
"logs_indexed_live_index_indexed_sum",
"logs_live_indexed_logs_usage_sum",
"logs_live_indexed_count_agg_sum",
"live_indexed_events_sum",
)
snap.indexed_logs_rehydrated = _f(item,
"logs_rehydrated_indexed_count_agg_sum",
"rehydrated_indexed_events_sum",
)
snap.indexed_logs_3day = _f(item,
"logs_indexed_logs_usage_sum_3_day", # newer naming
"logs_indexed_3day_agg_sum",
"logs_indexed_3_day_agg_sum",
)
snap.indexed_logs_7day = _f(item,
"logs_indexed_logs_usage_sum_7_day",
"logs_indexed_7day_agg_sum",
"logs_indexed_7_day_agg_sum",
)
snap.indexed_logs_15day = _f(item,
"logs_indexed_logs_usage_sum_15_day",
"logs_indexed_15day_agg_sum",
"logs_indexed_15_day_agg_sum",
"logs_indexed_logs_indexed_15day_sum",
)
snap.indexed_logs_30day = _f(item,
"logs_indexed_logs_usage_sum_30_day",
"logs_indexed_30day_agg_sum",
"logs_indexed_30_day_agg_sum",
"logs_indexed_logs_indexed_30day_sum",
)
snap.indexed_logs_45day = _f(item,
"logs_indexed_logs_usage_sum_45_day",
"logs_indexed_45day_agg_sum",
"logs_indexed_45_day_agg_sum",
"logs_indexed_logs_indexed_45day_sum",
)
snap.indexed_logs_60day = _f(item,
"logs_indexed_logs_usage_sum_60_day",
"logs_indexed_60day_agg_sum",
"logs_indexed_60_day_agg_sum",
)
snap.indexed_logs_90day = _f(item,
"logs_indexed_logs_usage_sum_90_day",
"logs_indexed_90day_agg_sum",
"logs_indexed_90_day_agg_sum",
"logs_indexed_logs_indexed_90day_sum",
)
snap.indexed_logs_180day = _f(item,
"logs_indexed_logs_usage_sum_180_day",
"logs_indexed_180day_agg_sum",
"logs_indexed_180_day_agg_sum",
)
snap.indexed_logs_360day = _f(item,
"logs_indexed_logs_usage_sum_360_day",
"logs_indexed_360day_agg_sum",
"logs_indexed_360_day_agg_sum",
)
# SIEM / security logs
snap.security_logs_bytes = _f(item,
"siem_ingested_bytes_agg_sum",
"siem_analyzed_logs_add_on_count_sum",
)
# APM / Tracing
snap.ingested_spans_bytes = _f(item,
"twol_ingested_events_bytes_sum", # Tracing Without Limits — primary ingestion field
"ingested_spans_bytes_agg_sum",
"ingested_spans_bytes_sum",
)
# apm_ingest_gb_sum only covers overages above the 150 GB/APM-host/month free tier;
# use it only as a last resort when no byte-level field found, and convert GB → bytes.
if snap.ingested_spans_bytes == 0:
_apm_overage_gb = _f(item, "apm_ingest_gb_sum", "apm_ingest_only_gb_sum")
if _apm_overage_gb:
snap.ingested_spans_bytes = _apm_overage_gb * 1e9
snap.indexed_spans = _f(item,
"trace_search_indexed_events_count_sum", # newer naming
"trace_search_indexed_events_count_agg_sum",
"apm_span_custom_agg_sum",
"indexed_events_count_sum",
)
snap.custom_events = _f(item,
"custom_events_agg_sum", "custom_events_sum",
)
# Serverless
snap.serverless_functions = _f(item,
"serverless_func_count_avg_sum", "serverless_func_avg_sum",
"serverless_func_count_agg_sum",
)
snap.serverless_invocations = _f(item,
"lambda_invocations_count_agg_sum",
"serverless_invocation_count_agg_sum",
"aws_lambda_invocations_sum",
)
snap.serverless_app_instances = _f(item,
"serverless_apps_total_count_hw_max_sum",
"serverless_apps_azure_count_hw_max_sum",
)
# RUM
# Total RUM Investigate = all session types summed
rum_total = _f(item,
"rum_total_session_count_sum",
"rum_browser_and_mobile_session_count_sum",
"rum_session_count_sum",
)
rum_lite = _f(item,
"rum_lite_session_count_sum",
"rum_browser_lite_session_count_sum",
"rum_lite_session_count_agg_sum",
"rum_browser_lite_session_count_agg_sum",
)
rum_replay = _f(item,
"rum_replay_session_count_sum",
"rum_browser_replay_session_count_sum",
"rum_replay_session_count_agg_sum",
"session_replay_count_agg_sum",
)
rum_legacy = _f(item,
"rum_browser_legacy_session_count_sum",
"browser_legacy_session_count_sum",
)
# If the total session count field is missing, sum the parts
snap.rum_sessions = rum_total or (rum_lite + rum_replay + rum_legacy)
snap.rum_lite_sessions = rum_lite
snap.rum_replay = rum_replay
snap.session_replay = rum_replay # alias
snap.rum_errors = _f(item,
"error_tracking_error_events_sum", # newer naming
"error_tracking_events_sum",
"error_tracking_events_agg_sum",
"total_error_tracking_events_agg_sum",
)
# Synthetics
snap.synthetics_api = _f(item,
"synthetics_check_calls_count_agg_sum",
"synthetics_check_calls_count_sum",
)
snap.synthetics_browser = _f(item,
"synthetics_browser_check_calls_count_sum", # newer naming
"synthetics_browser_check_calls_count_agg_sum",
"browser_check_calls_count_agg_sum",
)
# Incident / DBM / CI / Other
snap.incident_management_seats = _f(item,
"incident_management_seats_hwm",
"incident_management_monthly_active_users_hwm",
"incident_management_monthly_active_users_hw_max_sum",
"incident_management_monthly_active_users_hw_max",
)
snap.test_optimization_committers = _f(item,
"ci_visibility_pipeline_committers_hwm", # newer naming
"ci_visibility_itsm_committers_hw_max_sum",
"ci_visibility_committers_hw_max_sum",
)
snap.test_optimization_spans = _f(item,
"ci_pipeline_indexed_spans_sum", # newer naming
"ci_test_indexed_spans_agg_sum",
"ci_test_indexed_spans_sum",
"ci_visibility_test_indexed_spans_agg_sum",
)
snap.product_analytics_sessions = _f(item,
"product_analytics_sum",
"product_analytics_count_agg_sum",
"product_analytics_session_count_agg_sum",
)
snap.app_builder_apps = _f(item, "published_app_hwm_sum", "published_app_hw_max_sum")
snap.bits_ai_investigations = _f(item,
"bits_ai_investigations_sum",
"bits_ai_total_conversations_agg_sum",
"bits_ai_investigations_agg_sum",
"ai_credits_bits_sre_ai_credits_sum",
)
# ── Store raw for JSON export ────────────────────────────────────────────
snap.raw = {
"usage_summary": summary_raw,
}
return snap
# ═══════════════════════════════════════════════════════════════════════════
# SECTION 5 — Coralogix conversion (matches the Excel template formulas)
# ═══════════════════════════════════════════════════════════════════════════
def compute_coralogix_sizing(snap: UsageSnapshot) -> CoralogixSizing:
"""Apply the sizing formulas from the Excel template to the usage snapshot."""
cx = CoralogixSizing()
# ── Logs ─────────────────────────────────────────────────────────────────
ingested_gb = snap.ingested_logs_bytes / 1e9
security_gb = snap.security_logs_bytes / 1e9
cx.total_ingested_logs_gb_month = ingested_gb + security_gb
# Indexed logs = live/short-term + rehydrated + 15-day + 90-day+ retention
# Map: Live & Rehydrated = (3day + 7day + live + rehydrated)
# 15-day tier = indexed_15day
# 90-day+ tier = 30d + 45d + 60d + 90d + 180d + 360d
indexed_live_rehydrated = (
snap.indexed_logs_3day
+ snap.indexed_logs_7day
+ snap.indexed_logs_live
+ snap.indexed_logs_rehydrated
)
indexed_15d = snap.indexed_logs_15day
indexed_long = (
snap.indexed_logs_30day + snap.indexed_logs_45day
+ snap.indexed_logs_60day + snap.indexed_logs_90day
+ snap.indexed_logs_180day + snap.indexed_logs_360day
)
cx.total_indexed_logs_count = indexed_live_rehydrated + indexed_15d + indexed_long
# Size in bytes: count × avg_log_size_kb × 1024 (bytes per KB)
# Then convert bytes → GB: ÷ 1024³
indexed_bytes = cx.total_indexed_logs_count * AVG_LOG_SIZE_KB * 1024
cx.indexed_logs_size_gb_month = indexed_bytes / (1024 ** 3)
if cx.total_ingested_logs_gb_month > 0:
cx.indexed_pct_logs = cx.indexed_logs_size_gb_month / cx.total_ingested_logs_gb_month
cx.daily_logs_gb = cx.total_ingested_logs_gb_month / DAYS_PER_MONTH
cx.daily_logs_mon_gb = cx.daily_logs_gb * LOG_TIER_MON
cx.daily_logs_comp_gb = cx.daily_logs_gb * LOG_TIER_COMP
# ── Metrics ──────────────────────────────────────────────────────────────
# Hosts = infra + apm + profiled + network + fargate types
cx.host_count = (
snap.infra_hosts + snap.apm_hosts + snap.profiled_hosts + snap.network_hosts
+ snap.fargate_tasks + snap.profiled_fargate + snap.apm_fargate
)
cx.container_count = snap.containers + snap.profiled_containers
cx.host_container_ts = (cx.host_count + cx.container_count) * TS_PER_HOST
# Serverless metrics: daily functions/invocations × 3 labels × 10% unique dimensions
sw_func_daily = snap.serverless_functions / DAYS_PER_MONTH
sw_invoc_daily = snap.serverless_invocations / DAYS_PER_MONTH
cx.sw_func_ts = sw_func_daily * SW_LABEL_FACTOR
cx.sw_invoc_ts = sw_invoc_daily * SW_LABEL_FACTOR
cx.total_ts = cx.host_container_ts + snap.custom_metrics + cx.sw_func_ts + cx.sw_invoc_ts
cx.metrics_units_per_day = cx.total_ts * TS_TO_UNITS
# ── Tracing ──────────────────────────────────────────────────────────────
cx.ingested_spans_gb_month = snap.ingested_spans_bytes / 1e9
# Indexed spans GB = (count + custom_events) × avg_span_size_kb / 1024² (KB→GB)
cx.indexed_spans_gb_month = (
(snap.indexed_spans + snap.custom_events) * AVG_SPAN_SIZE_KB
) / (1024 * 1024)
if cx.ingested_spans_gb_month > 0:
cx.indexed_pct_spans = cx.indexed_spans_gb_month / cx.ingested_spans_gb_month
cx.daily_spans_ingest_gb = cx.ingested_spans_gb_month / DAYS_PER_MONTH
cx.daily_spans_mon_gb = cx.daily_spans_ingest_gb * SPAN_TIER_MON
cx.daily_spans_comp_gb = cx.daily_spans_ingest_gb * SPAN_TIER_COMP
cx.daily_spans_indexed_gb = cx.daily_spans_ingest_gb * cx.indexed_pct_spans
cx.daily_spans_archive_gb = cx.daily_spans_ingest_gb - cx.daily_spans_indexed_gb
# ── RUM ──────────────────────────────────────────────────────────────────
cx.rum_sessions_monthly = snap.rum_sessions
cx.rum_sessions_daily = snap.rum_sessions / DAYS_PER_MONTH
cx.rum_session_recording_daily = snap.session_replay / DAYS_PER_MONTH
cx.rum_errors_per_day = snap.rum_errors / DAYS_PER_MONTH
# ── Synthetics → Checkly ─────────────────────────────────────────────────
cx.synthetics_api_monthly = snap.synthetics_api
cx.synthetics_browser_monthly = snap.synthetics_browser
cx.synthetics_api_daily = snap.synthetics_api / DAYS_PER_MONTH
cx.synthetics_browser_daily = snap.synthetics_browser / DAYS_PER_MONTH
return cx
# ═══════════════════════════════════════════════════════════════════════════
# SECTION 6 — Formatting helpers
# ═══════════════════════════════════════════════════════════════════════════
def _fmt(n: float | None, decimals: int = 1, suffix: str = "") -> str:
if n is None:
return "N/A"
if n == 0:
return f"0{suffix}"
if abs(n) >= 1e12:
return f"{n/1e12:.{decimals}f}T{suffix}"
if abs(n) >= 1e9:
return f"{n/1e9:.{decimals}f}B{suffix}"
if abs(n) >= 1e6:
return f"{n/1e6:.{decimals}f}M{suffix}"
if abs(n) >= 1e3:
return f"{n/1e3:.{decimals}f}K{suffix}"
return f"{n:.{decimals}f}{suffix}"
def _bytes_to_tb(b: float) -> str:
return f"{b/1e12:.2f} TB"
def _bytes_to_gb(b: float) -> str:
return f"{b/1e9:.2f} GB"
# ═══════════════════════════════════════════════════════════════════════════
# SECTION 6b — Multi-month trend analysis
# ═══════════════════════════════════════════════════════════════════════════
def compute_trends(
pairs: list[tuple["UsageSnapshot", "CoralogixSizing"]],
) -> list[dict]:
"""Compute month-over-month % changes for the key TCO metrics."""
results: list[dict] = []
for i, (snap, cx) in enumerate(pairs):
entry: dict = {
"month": snap.month,
"logs_gb_day": cx.daily_logs_gb,
"metrics_ts": cx.total_ts,
"tracing_gb_day": cx.daily_spans_ingest_gb,
"rum_day": cx.rum_sessions_daily,
"rum_rec_day": cx.rum_session_recording_daily,
}
if i > 0:
prev = results[i - 1]
def _pct(curr: float, prev_val: float) -> float | None:
if prev_val:
return (curr - prev_val) / abs(prev_val) * 100
return None
entry["logs_pct"] = _pct(entry["logs_gb_day"], prev["logs_gb_day"])
entry["metrics_pct"] = _pct(entry["metrics_ts"], prev["metrics_ts"])
entry["tracing_pct"] = _pct(entry["tracing_gb_day"], prev["tracing_gb_day"])
entry["rum_pct"] = _pct(entry["rum_day"], prev["rum_day"])
else:
entry["logs_pct"] = entry["metrics_pct"] = entry["tracing_pct"] = entry["rum_pct"] = None
results.append(entry)
return results
def _trend_arrow(pct: float | None) -> str:
"""Return a coloured HTML arrow for a % change."""
if pct is None:
return '<span style="color:#aaa">—</span>'
if pct > 5:
return f'<span style="color:#e04b2a">▲ {pct:+.1f}%</span>'
if pct < -5:
return f'<span style="color:#22a06b">▼ {pct:+.1f}%</span>'
return f'<span style="color:#888">≈ {pct:+.1f}%</span>'
# ═══════════════════════════════════════════════════════════════════════════
# SECTION 7 — CSV output
# ═══════════════════════════════════════════════════════════════════════════
def generate_csv(snap: UsageSnapshot, cx: CoralogixSizing) -> bytes:
buf = io.StringIO()
w = csv.writer(buf)
w.writerow(["Datadog Usage Report", snap.month])
w.writerow(["Account", snap.account_name or "N/A"])
w.writerow(["Site", snap.site])
w.writerow(["Pulled at", snap.pulled_at])
w.writerow(["Note", FRESHNESS_NOTE])
w.writerow([])
# ── Bill Overview tiles ───────────────────────────────────────────────
w.writerow(["=== DATADOG BILL OVERVIEW ==="])
w.writerow(["Metric", "Value", "Unit"])
tiles = [
("Infra Hosts", snap.infra_hosts, "hosts (avg concurrent)"),
("APM Hosts", snap.apm_hosts, "hosts (avg concurrent)"),
("Custom Metrics", snap.custom_metrics, "time series"),
("Ingested Custom Metrics", snap.ingested_custom_metrics, "time series"),
("Indexed Logs (3 Day)", snap.indexed_logs_3day, "events"),
("Indexed Logs (7 Day)", snap.indexed_logs_7day, "events"),
("Indexed Logs (15 Day)", snap.indexed_logs_15day, "events"),
("Indexed Logs (30 Day)", snap.indexed_logs_30day, "events"),
("Indexed Logs (45 Day)", snap.indexed_logs_45day, "events"),
("Indexed Logs (60 Day)", snap.indexed_logs_60day, "events"),
("Indexed Logs (90 Day)", snap.indexed_logs_90day, "events"),
("Indexed Logs (180 Day)", snap.indexed_logs_180day, "events"),
("Indexed Logs (360 Day)", snap.indexed_logs_360day, "events"),
("Indexed Logs (Live Search)", snap.indexed_logs_live, "events"),
("Indexed Logs (Rehydrated)", snap.indexed_logs_rehydrated, "events"),
("Ingested Logs", snap.ingested_logs_bytes, "bytes"),
("Container Hours", snap.container_hours, "container-hours/month"),
("Containers (avg concurrent)", snap.containers, "containers"),
("Ingested Spans", snap.ingested_spans_bytes, "bytes"),
("Indexed Spans", snap.indexed_spans, "events"),
("Profiled Hosts", snap.profiled_hosts, "hosts"),
("Profiled Container Hours", snap.profiled_containers, "container-hours"),
("Serverless Workload Functions", snap.serverless_functions, "functions"),
("Serverless Invocations", snap.serverless_invocations, "invocations"),
("Serverless App Instances", snap.serverless_app_instances, "instances"),
("Fargate Tasks", snap.fargate_tasks, "tasks"),
("APM Fargate Tasks", snap.apm_fargate, "tasks"),
("Profiled Fargate Tasks", snap.profiled_fargate, "tasks"),
("Network Hosts", snap.network_hosts, "hosts"),
("DBM Hosts", snap.dbm_hosts, "hosts"),
("Synthetics API Test Runs", snap.synthetics_api, "test runs"),
("Synthetics Browser Test Runs", snap.synthetics_browser, "test runs"),
("RUM Investigate (Sessions)", snap.rum_sessions, "sessions"),
("RUM Measure (Lite Sessions)", snap.rum_lite_sessions, "sessions"),
("Session Replay", snap.rum_replay, "sessions"),
("Error Tracking Events", snap.rum_errors, "events"),
("Incident Management Seats", snap.incident_management_seats, "seats"),
("Custom Events", snap.custom_events, "events"),
("Product Analytics Sessions", snap.product_analytics_sessions, "sessions"),
("Test Optimization Committers", snap.test_optimization_committers, "committers"),
("Test Optimization Spans", snap.test_optimization_spans, "spans"),
("App Builder Published Apps", snap.app_builder_apps, "apps"),
("Bits AI SRE Investigations", snap.bits_ai_investigations, "investigations"),
("SIEM/Security Logs", snap.security_logs_bytes, "bytes"),
]
for name, value, unit in tiles:
w.writerow([name, value, unit])
w.writerow([])
# ── Coralogix sizing ─────────────────────────────────────────────────
w.writerow(["=== CORALOGIX SIZING ==="])
w.writerow(["Assumption: avg log size (KB)", AVG_LOG_SIZE_KB])
w.writerow(["Assumption: avg span size (KB)", AVG_SPAN_SIZE_KB])
w.writerow(["Assumption: TS per host/container", TS_PER_HOST])
w.writerow(["Assumption: TS-to-Units factor", TS_TO_UNITS])
w.writerow(["Assumption: days per month", DAYS_PER_MONTH])
w.writerow([])
w.writerow(["-- Logs --"])
w.writerow(["Total Ingested Logs (GB/month)", f"{cx.total_ingested_logs_gb_month:.2f}"])
w.writerow(["Total Indexed Logs (events/month)", f"{cx.total_indexed_logs_count:.0f}"])
w.writerow(["Total Indexed Logs Size (GB/month)", f"{cx.indexed_logs_size_gb_month:.2f}"])
w.writerow(["Indexed Percentage", f"{cx.indexed_pct_logs*100:.2f}%"])
w.writerow(["Daily Ingested Logs (GB/day)", f"{cx.daily_logs_gb:.2f}"])
w.writerow([" Monitoring 70% (GB/day)", f"{cx.daily_logs_mon_gb:.2f}"])
w.writerow([" Compliance 30% (GB/day)", f"{cx.daily_logs_comp_gb:.2f}"])
w.writerow([])
w.writerow(["-- Metrics --"])
w.writerow(["Host count (all types)", f"{cx.host_count:.0f}"])
w.writerow(["Container count", f"{cx.container_count:.0f}"])
w.writerow(["Host+Container TimeSeries", f"{cx.host_container_ts:.0f}"])
w.writerow(["Serverless Functions TS", f"{cx.sw_func_ts:.2f}"])
w.writerow(["Serverless Invocations TS", f"{cx.sw_invoc_ts:.2f}"])
w.writerow(["Total TimeSeries (NumSeries)", f"{cx.total_ts:.0f}"])
w.writerow(["Metrics Units/day", f"{cx.metrics_units_per_day:.2f}"])
w.writerow([])
w.writerow(["-- Tracing --"])
w.writerow(["Ingested Spans (GB/month)", f"{cx.ingested_spans_gb_month:.2f}"])
w.writerow(["Indexed Spans (GB/month)", f"{cx.indexed_spans_gb_month:.2f}"])
w.writerow(["Indexed Span Percentage", f"{cx.indexed_pct_spans*100:.4f}%"])
w.writerow(["Daily Ingested Spans (GB/day)", f"{cx.daily_spans_ingest_gb:.2f}"])
w.writerow([" Monitoring 10% (GB/day)", f"{cx.daily_spans_mon_gb:.2f}"])
w.writerow([" Compliance 90% (GB/day)", f"{cx.daily_spans_comp_gb:.2f}"])
w.writerow([" Indexed (GB/day)", f"{cx.daily_spans_indexed_gb:.4f}"])
w.writerow([" Archive (GB/day)", f"{cx.daily_spans_archive_gb:.2f}"])
w.writerow([])
w.writerow(["-- RUM --"])
w.writerow(["RUM Sessions/month", f"{cx.rum_sessions_monthly:.0f}"])
w.writerow(["RUM Total Sessions/day", f"{cx.rum_sessions_daily:.0f}"])
w.writerow(["RUM Session Recording/day", f"{cx.rum_session_recording_daily:.0f}"])
w.writerow(["RUM Errors/day", f"{cx.rum_errors_per_day:.2f}"])
w.writerow([])
w.writerow(["-- Summary for TCO Calculator --"])
w.writerow(["Logs GB/day", f"{cx.daily_logs_gb:.2f}"])
w.writerow(["Metrics NumSeries", f"{cx.total_ts:.0f}"])
w.writerow(["Tracing GB/day", f"{cx.daily_spans_ingest_gb:.2f}"])
w.writerow(["RUM Total Sessions/day", f"{cx.rum_sessions_daily:.0f}"])
w.writerow(["RUM Session Recording/day", f"{cx.rum_session_recording_daily:.0f}"])
w.writerow([])
w.writerow(["-- Summary for Checkly --"])
w.writerow(["API checks / day", f"{cx.synthetics_api_daily:.0f}"])
w.writerow(["Browser checks / day", f"{cx.synthetics_browser_daily:.0f}"])
w.writerow(["API checks / month", f"{cx.synthetics_api_monthly:.0f}"])
w.writerow(["Browser checks / month", f"{cx.synthetics_browser_monthly:.0f}"])
return buf.getvalue().encode()
# ═══════════════════════════════════════════════════════════════════════════
# SECTION 8 — Excel output (mirrors the template sheet layout)
# ═══════════════════════════════════════════════════════════════════════════
def generate_xlsx(
snap: UsageSnapshot,
cx: CoralogixSizing,
all_pairs: list[tuple["UsageSnapshot", "CoralogixSizing"]] | None = None,
) -> bytes | None:
if not HAS_OPENPYXL:
return None
wb = openpyxl.Workbook()
# ── Helper styles ─────────────────────────────────────────────────────
_GREEN = "008F61"
_GREEN_L = "00B37A"
_INK = "1A2332"
_LGRAY = "F5F5F5"
_DGRAY = "3C3C3C"
_WHITE = "FFFFFF"
def hdr_cell(ws, row, col, value, bg=_GREEN, fg=_WHITE, bold=True, sz=11):
c = ws.cell(row=row, column=col, value=value)
c.font = Font(bold=bold, color=fg, size=sz)
c.fill = PatternFill("solid", fgColor=bg)
c.alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
return c
def label_cell(ws, row, col, value, bold=False, bg=None):
c = ws.cell(row=row, column=col, value=value)
c.font = Font(bold=bold, size=10)
if bg:
c.fill = PatternFill("solid", fgColor=bg)
return c
def val_cell(ws, row, col, value, number_format=None):
c = ws.cell(row=row, column=col, value=value)
c.font = Font(size=10)
c.alignment = Alignment(horizontal="right")
if number_format:
c.number_format = number_format
return c
# ════════════════════════════════════════════════════════════════════
# Sheet 1 — Bill Overview
# ════════════════════════════════════════════════════════════════════
ws1 = wb.active
ws1.title = "Bill Overview"
ws1.column_dimensions["A"].width = 38
ws1.column_dimensions["B"].width = 20
ws1.column_dimensions["C"].width = 22
ws1.column_dimensions["D"].width = 22
ws1.row_dimensions[1].height = 28
hdr_cell(ws1, 1, 1, f"Datadog Bill Overview — {snap.month}", bg=_GREEN, sz=13)
ws1.merge_cells("A1:D1")
ws1.cell(row=2, column=1, value=f"Account: {snap.account_name or 'N/A'} | Site: {snap.site} | Pulled: {snap.pulled_at[:10]}")
ws1.merge_cells("A2:D2")
ws1.cell(row=3, column=1, value=f"Note: {FRESHNESS_NOTE}").font = Font(italic=True, size=9, color="666666")
ws1.merge_cells("A3:D3")
hdr_cell(ws1, 5, 1, "Product Metric", bg=_DGRAY, sz=10)
hdr_cell(ws1, 5, 2, "Raw Value", bg=_DGRAY, sz=10)
hdr_cell(ws1, 5, 3, "Formatted", bg=_DGRAY, sz=10)
hdr_cell(ws1, 5, 4, "Unit", bg=_DGRAY, sz=10)
tiles = [
("Infrastructure", None, None, ""),
("Infra Hosts", snap.infra_hosts, _fmt(snap.infra_hosts, 0), "hosts (avg concurrent)"),
("APM Hosts", snap.apm_hosts, _fmt(snap.apm_hosts, 0), "hosts (avg concurrent)"),
("Container Hours", snap.container_hours, _fmt(snap.container_hours), "container-hours/month"),
("Containers (avg concurrent)", snap.containers, _fmt(snap.containers, 0), "containers"),
("Network Hosts", snap.network_hosts, _fmt(snap.network_hosts, 0), "hosts"),
("DBM Hosts", snap.dbm_hosts, _fmt(snap.dbm_hosts, 0), "hosts"),
("", None, None, ""),
("Custom Metrics", None, None, ""),
("Custom Metrics", snap.custom_metrics, _fmt(snap.custom_metrics), "time series"),
("Ingested Custom Metrics", snap.ingested_custom_metrics, _fmt(snap.ingested_custom_metrics), "time series"),
("", None, None, ""),
("Logs", None, None, ""),
("Ingested Logs", snap.ingested_logs_bytes, _bytes_to_tb(snap.ingested_logs_bytes), "bytes"),
("Indexed Logs (3 Day)", snap.indexed_logs_3day, _fmt(snap.indexed_logs_3day), "events"),
("Indexed Logs (7 Day)", snap.indexed_logs_7day, _fmt(snap.indexed_logs_7day), "events"),
("Indexed Logs (15 Day)", snap.indexed_logs_15day, _fmt(snap.indexed_logs_15day), "events"),
("Indexed Logs (30 Day)", snap.indexed_logs_30day, _fmt(snap.indexed_logs_30day), "events"),
("Indexed Logs (45 Day)", snap.indexed_logs_45day, _fmt(snap.indexed_logs_45day), "events"),
("Indexed Logs (60 Day)", snap.indexed_logs_60day, _fmt(snap.indexed_logs_60day), "events"),
("Indexed Logs (90 Day)", snap.indexed_logs_90day, _fmt(snap.indexed_logs_90day), "events"),
("Indexed Logs (180 Day)", snap.indexed_logs_180day, _fmt(snap.indexed_logs_180day), "events"),
("Indexed Logs (360 Day)", snap.indexed_logs_360day, _fmt(snap.indexed_logs_360day), "events"),
("Indexed Logs (Live Search)", snap.indexed_logs_live, _fmt(snap.indexed_logs_live), "events"),
("Indexed Logs (Rehydrated)", snap.indexed_logs_rehydrated, _fmt(snap.indexed_logs_rehydrated), "events"),
("SIEM / Security Logs", snap.security_logs_bytes, _bytes_to_gb(snap.security_logs_bytes), "bytes"),
("", None, None, ""),
("APM / Tracing", None, None, ""),
("Ingested Spans", snap.ingested_spans_bytes, _bytes_to_tb(snap.ingested_spans_bytes), "bytes"),
("Indexed Spans", snap.indexed_spans, _fmt(snap.indexed_spans), "events"),
("Profiled Hosts", snap.profiled_hosts, _fmt(snap.profiled_hosts, 0), "hosts"),
("Profiled Container Hours", snap.profiled_containers, _fmt(snap.profiled_containers), "container-hours"),
("APM Fargate Tasks", snap.apm_fargate, _fmt(snap.apm_fargate, 0), "tasks"),