Metric Instant Query Node in Pathways

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

Overview

The Metric Instant Query node in FojiSoft Pathways allows users to execute a metric query at a specific point in time. This node is particularly useful for retrieving real-time or historical performance metrics from monitoring systems, enabling automation based on live data.


Node Properties

1. Name

  • Description: A unique identifier for the metric query operation.
  • Usage: Assign a clear and descriptive name (e.g., "Fetch Server CPU Usage" or "Retrieve API Latency").

2. Query

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

3. Time

  • Description: Specifies the exact timestamp for the metric query execution.
  • Options: Same as Query Type (JavaScript Statement, JavaScript Function, Handlebars Template).
  • Example Expressions:
    • JavaScript Statement: Date.now()  // Fetch metric at the current time
    • JavaScript Function: function getQueryTime() {   return Date.now() - 60000; // Fetch metric from 1 minute ago }
    • Handlebars Template: query_time_variable

4. 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., cpu_usage, api_latency).

How It Works

  1. Define the Query: Select a query expression to retrieve the relevant metric.
  2. Specify the Time: Choose a timestamp for when the query should be executed.
  3. Store Output in a Variable: The retrieved metric data is saved under the specified variable name.

Example Use Cases

1. Monitoring Server Performance

  • Query: "server_cpu_usage"
  • Time: Date.now()
  • Variable Name: cpu_data
  • Outcome: Retrieves the current CPU usage of a server.

2. Checking API Latency Trends

  • Query: "api_response_time"
  • Time: Date.now() - 60000 (1 minute ago)
  • Variable Name: api_latency
  • Outcome: Fetches API response latency from the past minute.

Best Practices

  • Use Meaningful Variable Names: Helps with workflow clarity and debugging.
  • Leverage JavaScript Functions: For more complex query generation and timestamp manipulation.
  • Optimize Query Execution: Avoid excessive querying by setting appropriate time intervals.

The Metric Instant Query node is essential for integrating real-time performance data into automated workflows, allowing users to build intelligent, responsive systems.