CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-io-cdap-cdap--cdap-watchdog

CDAP Watchdog provides comprehensive metrics collection, querying, and logging services for the CDAP platform

Pending
Overview
Eval results
Files

metrics-query.mddocs/

Metrics Query API

REST-based metrics querying system providing HTTP endpoints for searching tags, querying time series data, and executing batch queries across the CDAP metrics storage system.

Capabilities

MetricsQueryService

Main HTTP service for metrics querying with service discovery registration, providing the foundation for metrics REST API endpoints.

/**
 * HTTP service for metrics querying with service discovery registration
 * Manages lifecycle of metrics query endpoints and integrates with CDAP service discovery
 */
public class MetricsQueryService extends AbstractIdleService {
    /**
     * Starts the metrics query HTTP service
     * @throws Exception if service startup fails
     */
    protected void startUp() throws Exception;
    
    /**
     * Stops the metrics query HTTP service
     * @throws Exception if service shutdown fails  
     */
    protected void shutDown() throws Exception;
}

MetricsHandler

REST endpoint handler providing HTTP endpoints for metrics search and query operations.

/**
 * REST endpoint handler for metrics operations
 * Provides HTTP endpoints for searching tags/metrics and querying metrics data
 */
public class MetricsHandler extends AbstractHttpHandler {
    // REST endpoints handled by this class:
    // POST /v3/metrics/search - Search for tags or metrics
    // POST /v3/metrics/query - Query metrics data (batch and single queries)
    // GET /v3/metrics/processor/status - Get metrics processor status
}

REST Endpoints:

  • POST /v3/metrics/search - Search for available tags or metrics
  • POST /v3/metrics/query - Execute metrics queries (supports both single and batch queries)
  • GET /v3/metrics/processor/status - Get current metrics processor status

Exception Handling

/**
 * Exception thrown when metrics REST API path parsing fails
 * Indicates malformed or invalid request paths in metrics endpoints
 */
public class MetricsPathException extends Exception {
    /**
     * Create exception with error message
     * @param message Description of the path parsing error
     */
    public MetricsPathException(String message);
    
    /**
     * Create exception with error message and cause
     * @param message Description of the path parsing error
     * @param cause Underlying exception that caused this error
     */
    public MetricsPathException(String message, Throwable cause);
}

Usage

The metrics query API is primarily accessed through HTTP requests to the MetricsQueryService. The service provides REST endpoints for:

  1. Tag and Metric Discovery: Use POST /v3/metrics/search to discover available tags and metrics
  2. Data Querying: Use POST /v3/metrics/query to execute time series and aggregate queries
  3. Status Monitoring: Use GET /v3/metrics/processor/status to check metrics processing status

Example HTTP Usage:

# Search for available metrics
curl -X POST "http://localhost:11015/v3/metrics/search" \
  -H "Content-Type: application/json" \
  -d '{"tags": ["namespace", "app"]}'

# Query metrics data
curl -X POST "http://localhost:11015/v3/metrics/query" \
  -H "Content-Type: application/json" \
  -d '{
    "tags": {"namespace": "myNamespace", "app": "myApp"}, 
    "metrics": ["system.cpu.usage"],
    "timeRange": {"start": "now-1h", "end": "now"}
  }'

Constants

// Common query constants from internal MetricsQueryHelper
public static final String NAMESPACE_STRING = "namespace";
public static final String APP_STRING = "app";

Install with Tessl CLI

npx tessl i tessl/maven-io-cdap-cdap--cdap-watchdog

docs

index.md

log-buffer.md

logging-context.md

logging-service.md

metrics-collection.md

metrics-processing.md

metrics-query.md

tile.json