1+ # Get query usage data for the given timeframe
2+ resource "ns1_billing_usage" "queries" {
3+ metric_type = " queries"
4+ from = 1731605824 # 2024-11-15 00:00:00 UTC
5+ to = 1734197824 # 2024-12-15 00:00:00 UTC
6+ }
7+
8+ # Get account limits data for the given timeframe
9+ resource "ns1_billing_usage" "limits" {
10+ metric_type = " limits"
11+ from = 1731605824 # 2024-11-15 00:00:00 UTC
12+ to = 1734197824 # 2024-12-15 00:00:00 UTC
13+ }
14+
15+ # Get RUM decisions usage data for the given timeframe
16+ resource "ns1_billing_usage" "decisions" {
17+ metric_type = " decisions"
18+ from = 1731605824 # 2024-11-15 00:00:00 UTC
19+ to = 1734197824 # 2024-12-15 00:00:00 UTC
20+ }
21+
22+ # Get filter chains usage data
23+ resource "ns1_billing_usage" "filter_chains" {
24+ metric_type = " filter-chains"
25+ }
26+
27+ # Get monitoring jobs usage data
28+ resource "ns1_billing_usage" "monitors" {
29+ metric_type = " monitors"
30+ }
31+
32+ # Get records usage data
33+ resource "ns1_billing_usage" "records" {
34+ metric_type = " records"
35+ }
36+
37+ # Example of using the data in other resources
38+ output "total_queries" {
39+ value = ns1_billing_usage. queries . clean_queries
40+ }
41+
42+ output "total_ddos_queries" {
43+ value = ns1_billing_usage. queries . ddos_queries
44+ }
45+
46+ output "total_nxd_responses" {
47+ value = ns1_billing_usage. queries . nxd_responses
48+ }
49+
50+ output "queries_limit" {
51+ value = ns1_billing_usage. limits . queries_limit
52+ }
53+
54+ output "total_decisions" {
55+ value = ns1_billing_usage. decisions . total_usage
56+ }
57+
58+ output "decisions_limit" {
59+ value = ns1_billing_usage. limits . decisions_limit
60+ }
61+
62+ output "total_filter_chains" {
63+ value = ns1_billing_usage. filter_chains . total_usage
64+ }
65+
66+ output "filter_chains_limit" {
67+ value = ns1_billing_usage. limits . filter_chains_limit
68+ }
69+
70+ output "total_monitors" {
71+ value = ns1_billing_usage. monitors . total_usage
72+ }
73+
74+ output "monitors_limit" {
75+ value = ns1_billing_usage. limits . monitors_limit
76+ }
77+
78+ output "total_records" {
79+ value = ns1_billing_usage. records . total_usage
80+ }
81+
82+ output "records_limit" {
83+ value = ns1_billing_usage. limits . records_limit
84+ }
0 commit comments