1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "metrics": [
10 {
11 "name": "http.server.request.duration",
12 "type": "histogram",
13 "unit": "s",
14 "bucket_boundaries": [
15 0.005,
16 0.01,
17 0.025,
18 0.05,
19 0.075,
20 0.1,
21 0.25,
22 0.5,
23 0.75,
24 1,
25 2.5,
26 5,
27 7.5,
28 10,
29 ],
30 "temporality": "cumulative",
31 "frequency_seconds": 60,
32 "attributes": {
33 "http.request.method": 6,
34 "http.route": 35,
35 "http.response.status_code": 14,
36 "user.id": 5000,
37 },
38 },
39 {
40 "name": "http.server.duration",
41 "type": "histogram",
42 "unit": "ms",
43 "temporality": "cumulative",
44 "attributes": {
45 "http.method": 6,
46 "http.route": 35,
47 "http.status_code": 14,
48 },
49 },
50 {
51 "name": "orders.created",
52 "type": "counter",
53 "frequency_seconds": 10,
54 "attributes": {
55 "payment.method": 5,
56 "order.id": 50000,
57 },
58 },
59 {
60 "name": "http.client.request.duration",
61 "type": "histogram",
62 "unit": "s",
63 "attributes": {
64 "http.request.method": 3,
65 "server.address": 4,
66 "url.path": {
67 "cardinality": 2000,
68 "samples": [
69 "/v1/charges/8812",
70 "/v1/charges/9921/refunds",
71 "/v1/customers/1200/cards",
72 "/v1/charges/1203",
73 ],
74 },
75 },
76 },
77 ],
78 "analysisName": "checkout-service (production)",
79 "resourceAttributes": {
80 "service.name": 1,
81 "deployment.environment.name": 1,
82 "k8s.pod.name": 12,
83 },
84 "collectorConfig": """receivers:
85 otlp:
86 protocols:
87 grpc:
88 endpoint: localhost:4317
89processors:
90 memory_limiter:
91 check_interval: 1s
92 limit_percentage: 80
93 spike_limit_percentage: 25
94 batch: {}
95exporters:
96 otlphttp:
97 endpoint: ${env:OTLP_ENDPOINT}
98service:
99 pipelines:
100 metrics:
101 receivers: [otlp]
102 processors: [memory_limiter, batch]
103 exporters: [otlphttp]
104""",
105}
106
107
108run = client.actor("michiganpublictech/otel-cardinality-analyzer").call(run_input=run_input)
109
110
111print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
112for item in client.dataset(run.default_dataset_id).iterate_items():
113 print(item)
114
115