Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to make filters? #323

Open
Alex0159 opened this issue Aug 23, 2024 · 0 comments
Open

how to make filters? #323

Alex0159 opened this issue Aug 23, 2024 · 0 comments

Comments

@Alex0159
Copy link

Hello! I get errors with the following configuration
...Failed to execute jsonpath... or ...Failed to extract json objects for metric...

data.json

{
  "status": "UP",
  "components": {
    "SERVICE_1": {
      "status": "UP",
      "details": {
        "name": "This is SERVICE_1",
        "info": {
          "updated": "2024-08-21T14:54:00.019521649",
          "additional_details": {
            "url": "http://localhost/service-1"
          }
        }
      }
    },
    "SERVICE_2": {
      "status": "UP",
      "details": {
        "name": "This is SERVICE_2",
        "info": {
          "updated": "2024-08-21T14:54:00.019521649",
          "additional_details": {
            "url": "http://localhost/service-2"
          }
        }
      }
    },
    "SERVICE_3": {
      "status": "DOWN",
      "details": {
        "name": "This is SERVICE_3",
        "info": {
          "updated": "2024-08-21T14:54:00.019521649",
          "additional_details": {
            "url": "http://localhost/service-3"
          }
        }
      }
    }
  }
}

config.yml:

---
modules:
  default:
    headers:
      X-Dummy: my-test-header
    metrics:

      - name: status
        type: object
        help: 'This is SERVICE_UP'
        path: '{.components..[?(@.status == "UP")]}'
        labels:
          component: '{.components..[?(@.status == "UP")]~}'
        values:
          UP: 1

      - name: status
        type: object
        help: 'This is SERVICE_DOWN'
        path: '{.components..[?(@.status == "DOWN")]}'
        labels:
          component: '{.components..[?(@.status == "DOWN")]~}'
        values:
          DOWN: 0

output expected:

# HELP status_UP This is SERVICE_UP
# TYPE status_UP untyped
status_UP{component="SERVICE_1"} 1
status_UP{component="SERVICE_2"} 1

# HELP status_DOWN This is SERVICE_DOWN
# TYPE status_DOWN untyped
status_DOWN{component="SERVICE_3"} 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant