⛏️GetSplunky!
Lv.1Intern
0 XP
0
Home Map Stats Drill Board Log In
CoursesArticlesSPL Cheat SheetCertification PathAboutPrivacyTerms

Splunky is an independent, free study resource. It is not affiliated with, endorsed by, or sponsored by Splunk or Cisco. Splunk, SPL and related marks are trademarks of Splunk, a Cisco company, and are used here only to identify the certifications this site helps you study for.

© 2026 Splunky

Back to Floor
Analytics Crucible • Room 3

Stream Arithmetic & .map() Transformations

Raw metrics often need unit scaling, clamping, or conditional logic—such as converting bytes to gigabytes or milliseconds to seconds.

In SignalFlow, .map(lambda x: ...) applies a point-by-point transformation function to every datapoint in each MTS of a stream. Because SignalFlow uses Python-like lambda syntax, you can perform arithmetic scaling, conditional ternary checks (x if x is not None else 0), or value capping directly on the stream.

You can also combine multiple streams element-wise using standard operators (+, -, *, /) when both streams share compatible dimensions, such as computing memory utilization % = (memory_used / memory_total) * 100.

Scaling & Conditional Mapping with .map()
# Convert bytes to GiB and replace missing/null datapoints with 0
gib = data('memory.used').map(lambda x: (x / 1073741824) if x is not None else 0)
gib.publish(label='Memory Used (GiB)')
When dividing two streams (like errors / total), guard against division by zero or missing values—an idle service with 0 requests will produce NaN/null if total is 0.

Knowledge Check

Prove your understanding to clear the room (Rewards XP)
Complete the SignalFlow point-by-point transformation to convert latency from milliseconds to seconds and output the result:
ms = data('http.duration_ms').mean(by='service')
sec = ms.
( x: x / 1000)
sec.
(label='Latency (s)')