Coder Social home page Coder Social logo

turbot / steampipe-plugin-prometheus Goto Github PK

View Code? Open in Web Editor NEW
17.0 9.0 4.0 401 KB

Use SQL to instantly query Prometheus metrics, alerts, labels and more. Open source CLI. No DB required.

Home Page: https://hub.steampipe.io/plugins/turbot/prometheus

License: Apache License 2.0

Makefile 0.39% PLSQL 1.80% Go 97.82%
steampipe steampipe-plugin postgresql postgresql-fdw sql prometheus prometheus-client hacktoberfest backup etl

steampipe-plugin-prometheus's Introduction

image

Prometheus Plugin for Steampipe

Use SQL to query instances, domains and more from Prometheus.

Quick start

Install the plugin with Steampipe:

steampipe plugin install prometheus

Configure the server address in ~/.steampipe/config/prometheus.spc:

connection "prometheus" {
  plugin  = "prometheus"
  address = "http://localhost:9090"
}

Run steampipe:

steampipe query

Query all the labels in your prometheus metrics:

select
  name,
  values
from
  prometheus_label
> select name, values from prometheus_label
+---------------+----------------------------------------------+
| name          | values                                       |
+---------------+----------------------------------------------+
| alertname     | ["TotalRequests"]                            |
| alertstate    | ["firing"]                                   |
| reason        | ["refused","resolution","timeout","unknown"] |
| interval      | ["10s"]                                      |
| version       | ["2.30.3","go1.17.1"]                        |
| code          | ["200","302","400","500","503"]              |
+---------------+----------------------------------------------+

Query data for a given metric (tables are dynamically created):

select
  code,
  handler,
  value
from
  prometheus_http_requests_total
+------+----------------------------+-------+
| code | handler                    | value |
+------+----------------------------+-------+
| 302  | /                          | 1     |
| 200  | /-/ready                   | 1     |
| 200  | /api/v1/alerts             | 1     |
| 200  | /api/v1/label/:name/values | 421   |
| 200  | /api/v1/labels             | 16    |
| 200  | /graph                     | 1     |
| 200  | /static/*filepath          | 4     |
+------+----------------------------+-------+

Engines

This plugin is available for the following engines:

Engine Description
Steampipe The Steampipe CLI exposes APIs and services as a high-performance relational database, giving you the ability to write SQL-based queries to explore dynamic data. Mods extend Steampipe's capabilities with dashboards, reports, and controls built with simple HCL. The Steampipe CLI is a turnkey solution that includes its own Postgres database, plugin management, and mod support.
Postgres FDW Steampipe Postgres FDWs are native Postgres Foreign Data Wrappers that translate APIs to foreign tables. Unlike Steampipe CLI, which ships with its own Postgres server instance, the Steampipe Postgres FDWs can be installed in any supported Postgres database version.
SQLite Extension Steampipe SQLite Extensions provide SQLite virtual tables that translate your queries into API calls, transparently fetching information from your API or service as you request it.
Export Steampipe Plugin Exporters provide a flexible mechanism for exporting information from cloud services and APIs. Each exporter is a stand-alone binary that allows you to extract data using Steampipe plugins without a database.
Turbot Pipes Turbot Pipes is the only intelligence, automation & security platform built specifically for DevOps. Pipes provide hosted Steampipe database instances, shared dashboards, snapshots, and more.

Developing

Prerequisites:

Clone:

git clone https://github.com/turbot/steampipe-plugin-prometheus.git
cd steampipe-plugin-prometheus

Build, which automatically installs the new version to your ~/.steampipe/plugins directory:

make

Configure the plugin:

cp config/* ~/.steampipe/config
vi ~/.steampipe/config/prometheus.spc

Try it!

steampipe query
> .inspect prometheus

Further reading:

Open Source & Contributing

This repository is published under the Apache 2.0 (source code) and CC BY-NC-ND (docs) licenses. Please see our code of conduct. We look forward to collaborating with you!

Steampipe is a product produced from this open source software, exclusively by Turbot HQ, Inc. It is distributed under our commercial terms. Others are allowed to make their own distribution of the software, but cannot use any of the Turbot trademarks, cloud services, etc. You can learn more in our Open Source FAQ.

Get Involved

Join #steampipe on Slack →

Want to help but don't know where to start? Pick up one of the help wanted issues:

steampipe-plugin-prometheus's People

Contributors

beudbeud avatar cbruno10 avatar dboeke avatar dependabot[bot] avatar e-gineer avatar khushboo9024 avatar madhushreeray30 avatar misraved avatar sidr0cker avatar subhajit97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

steampipe-plugin-prometheus's Issues

Plugin fails to initialize with `unhandled error: interface conversion: interface {} is nil`

Describe the bug
A clear and concise description of what the bug is.

steampipe-plugin-prometheus % steampipe query
Welcome to Steampipe v0.19.0-rc.10
For more information, type .help
> 
Warning: failed to start plugin 'hub.steampipe.io/plugins/turbot/prometheus@latest': failed to plugin initialise plugin 'steampipe-plugin-prometheus': TableMapFunc 'pluginTableDefinitions' had unhandled error: interface conversion: interface {} is nil, not string

Steampipe version (steampipe -v)
v0.19.0-rc.10

Plugin version (steampipe plugin list)
v0.1.0

Steampipe Plugin SDK version
v3.3.2

To reproduce
Setup prometheus, configure steampipe plugin and run steampipe query. It gives a warning TableMapFunc 'pluginTableDefinitions' had unhandled error: interface conversion: interface {} is nil, not string.

TableMapFunc 'pluginTableDefinitions' had unhandled error: interface conversion: interface {} is nil, not string

Describe the bug

steampipe installation works with other plugins but errors with Prometheus:

+---------------------------------------------------+-------------+------------------------+
| Failed                                            | Connections | Reason                 |
+---------------------------------------------------+-------------+------------------------+
| hub.steampipe.io/plugins/turbot/prometheus@latest | prometheus  | plugin failed to start |
+---------------------------------------------------+-------------+------------------------+

And:

[WARN]  failed to set connection config for hub.steampipe.io/plugins/turbot/prometheus@latest: failed to plugin initialise plugin 'steampipe-plugin-prometheus': TableMapFunc 'pluginTableDefinitions' had unhandled error: interface conversion: interface {} is nil, not string
[WARN]  initializePlugin failed: failed to plugin initialise plugin 'steampipe-plugin-prometheus': TableMapFunc 'pluginTableDefinitions' had unhandled error: interface conversion: interface {} is nil, not string (0xc000dea4c0)

Config:

connection "prometheus" {
  plugin = "prometheus"

  address = "http://localhost:9290/"
  metrics = [".+"]
}

And curl --silent --get http://localhost:9290/-/healthy and /-/ready good and can query e.g. /api/v1/targets etc.

Steampipe version (steampipe -v)
Steampipe v0.21.4

Plugin version (steampipe plugin list)
Example: @latest (by default) appears to be v0.6.1

To reproduce

  1. steampipe plugin install prometheus[@v0.6.1]
  2. Consult plugin log

Expected behavior
Success

Additional context

Probably a conversion 'feature' but installing without specifying a version:

+---------------------------------------------------+---------+-------------+
| Installed                                         | Version | Connections |
+---------------------------------------------------+---------+-------------+
| hub.steampipe.io/plugins/turbot/kubernetes@latest | 0.27.0  | kubernetes  |
| hub.steampipe.io/plugins/turbot/steampipe@latest  | 0.10.0  | steampipe   |
+---------------------------------------------------+---------+-------------+

+---------------------------------------------------+-------------+------------------------+
| Failed                                            | Connections | Reason                 |
+---------------------------------------------------+-------------+------------------------+
| hub.steampipe.io/plugins/turbot/prometheus@latest | prometheus  | plugin failed to start |
+---------------------------------------------------+-------------+------------------------+

And with a specific version:

 steampipe plugin install [email protected]
+---------------------------------------------------+---------+-------------+
| Installed                                         | Version | Connections |
+---------------------------------------------------+---------+-------------+
| hub.steampipe.io/plugins/turbot/kubernetes@latest | 0.27.0  | kubernetes  |
| hub.steampipe.io/plugins/turbot/[email protected]  | 0.6.1   |             |    < ------ LISTED
| hub.steampipe.io/plugins/turbot/steampipe@latest  | 0.10.0  | steampipe   |
+---------------------------------------------------+---------+-------------+

+---------------------------------------------------+-------------+------------------------+
| Failed                                            | Connections | Reason                 |
+---------------------------------------------------+-------------+------------------------+
| hub.steampipe.io/plugins/turbot/prometheus@latest | prometheus  | plugin failed to start |
+---------------------------------------------------+-------------+------------------------+

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.