Metric Range Query Node in Pathways

From FojiSoft Docs
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Overview

The Metric Range Query node in FojiSoft Pathways is used to execute a metric query over a defined range of time. This is particularly useful for analyzing trends, generating reports, and monitoring performance over a specific duration.


Node Properties

1. Name

  • Description: A unique identifier for the metric query operation.
  • Usage: Assign a descriptive name (e.g., "Retrieve Network Latency Data" or "Query CPU Usage Over Time").

2. Query

  • Description: Defines the metric query that will be executed.
  • Options for Expression Type:
    1. JavaScript Statement: A direct JavaScript expression for simple queries.
    2. JavaScript Function: A function for dynamic queries.
    3. Handlebars Template: A dynamic template for injecting real-time query values.
  • Example Expressions:
    • JavaScript Statement: "network_latency"
    • JavaScript Function: function getQuery() {   return "network_latency"; }
    • Handlebars Template: metric_query_variable
  • Status: Required (A valid query must be provided for execution).

3. Start Time

  • Description: Defines the earliest timestamp for querying data.
  • Options: Same as Query Type (JavaScript Statement, JavaScript Function, Handlebars Template).
  • Example Expressions:
    • JavaScript Statement: Date.now() - 900000  // Fetch data from 15 minutes ago
    • JavaScript Function: function getStartTime() {   return Date.now() - (60 * 60 * 1000); // Fetch data from 1 hour ago }
    • Handlebars Template: start_time_variable

4. End Time

  • Description: Defines the latest timestamp for querying data.
  • Options: Same as Start Time.
  • Example Expressions:
    • JavaScript Statement: Date.now()  // Fetch data up to the current time
    • JavaScript Function: function getEndTime() {   return Date.now(); }
    • Handlebars Template: end_time_variable

5. Query Step

  • Description: Determines the granularity of the data points retrieved (e.g., per second, per minute).
  • Default Value: 1 Minute
  • Customization: Adjust based on workflow needs (e.g., seconds, minutes, hours).
  • Example Use Cases:
    • High-resolution data: Set Step = 1 Second
    • Hourly summaries: Set Step = 1 Hour
    • Daily reports: Set Step = 1 Day

6. Variable Name

  • Description: The name of the output variable where the retrieved metric data will be stored.
  • Status: Required (Must be defined for further use in the workflow).
  • Usage: Choose a meaningful variable name (e.g., latency_trend, cpu_usage_history).

How It Works

  1. Define the Query: Specify the metric query to retrieve relevant data.
  2. Set Start and End Times: Choose a time range for data retrieval.
  3. Define Query Step: Controls how frequently data points are sampled.
  4. Store Output in a Variable: The retrieved metric data is saved under the specified variable name.

Example Use Cases

1. Analyzing Network Latency Trends

  • Query: "network_latency"
  • Start Time: Date.now() - 3600000 (1 hour ago)
  • End Time: Date.now()
  • Query Step: 1 Minute
  • Variable Name: latency_trend
  • Outcome: Retrieves network latency values over the past hour at 1-minute intervals.

2. Tracking CPU Utilization Over 24 Hours

  • Query: "cpu_usage"
  • Start Time: Date.now() - 86400000 (24 hours ago)
  • End Time: Date.now()
  • Query Step: 5 Minutes
  • Variable Name: cpu_usage_history
  • Outcome: Retrieves CPU utilization data for the past 24 hours in 5-minute increments.

Best Practices

  • Optimize Query Frequency: Avoid excessive data retrieval by setting appropriate step values.
  • Use Meaningful Variable Names: Helps with workflow clarity and debugging.
  • Leverage JavaScript Functions: For dynamic query adjustments based on system state.

The Metric Range Query node is essential for analyzing performance trends over time, providing valuable insights for monitoring and decision-making.