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

Framework to support exporters from configuration file #37

Merged
merged 14 commits into from
Jan 23, 2020

Conversation

ading1977
Copy link
Collaborator

@ading1977 ading1977 commented Jan 21, 2020

This pull request is the initial implementation of a general framework to support Prometheus exporters from configuration file. The appMetric component will now construct EntityMetric based on the following information defined in the configuration:

  • The exporter name
  • The entity type
  • The metric type
  • The metric kind (used or capacity) and its corresponding prometheus query
  • The entity attributes

The following is an example of the configuration for mysql exporter:

  - name: mysql
    entities:
      - type: APPLICATION
        metrics:
          DB_MEM:
            queries:
              used: 'mysql_global_status_innodb_buffer_pool_bytes_data{job="mysql"}'
              capacity: 'mysql_global_variables_innodb_buffer_pool_size{job="mysql"}'
          DB_CACHE_HIT_RATE:
            queries:
              used: '1/(1 + delta(mysql_global_status_innodb_buffer_pool_reads{job="mysql"}[10m])/rate(mysql_global_status_innodb_buffer_pool_read_requests[10m]))'
          CONNECTION:
            queries:
              used: 'mysql_global_status_threads_connected{job="mysql"}'
              capacity: 'mysql_global_variables_max_connections{job="mysql"}'
          TRANSACTION:
            queries:
              used: 'sum(rate(mysql_global_status_commands_total{command=~"(commit|rollback)"}[5m])) without (command)'
        attributes:
          ip:
            label: instance
            matches: \d{1,3}(?:\.\d{1,3}){3}(?::\d{1,5})??
            isIdentifier: true
          turboVersion:
            label: turbo_version
          node:
            label: node
          target:
            label: job

The following is the sample output:

{
    uid: "10.10.174.140", 
    type: 33,
    labels: {
        ip: "10.10.174.140",
        node: "ux1.foundation.eng.turbonomic.com",
        target: "mysql",
        turboVersion: "6.2.1-20180928133442000"
    },
    metrics: {
        44: {
            capacity: 151,
            used: 1
        },
        49: {
            used: 0
        },
        67: {
            capacity: 1073741824,
            used: 1073692672
        },
        69: {
            used: 0.04033115230470693
        }
    }
},

TODO:

  • Add detailed documentation/comments to the public data structures and methods
  • Parallelize prometheus queries with go-routines
  • Add unit tests
  • More extensive tests

This pull request also adds turbo custom metrics definition for istio 1.4.

Copy link
Contributor

@dblinn dblinn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Looks like there will be a good amount of integration effort on my part though haha. It would be good to increase our test coverage at some point though.

appmetric/cmd/main.go Show resolved Hide resolved
appmetric/cmd/main.go Show resolved Hide resolved
appmetric/cmd/main.go Show resolved Hide resolved
appmetric/cmd/main.go Show resolved Hide resolved
appmetric/cmd/main.go Outdated Show resolved Hide resolved
appmetric/pkg/prometheus/client.go Outdated Show resolved Hide resolved
appmetric/pkg/provider/metric.go Outdated Show resolved Hide resolved
used: '1000.0*rate(istio_turbo_pod_latency_time_ms_sum{response_code="200"}[3m])/rate(istio_turbo_pod_latency_time_ms_count{response_code="200"}[3m]) >= 0'
TRANSACTION:
queries:
used: 'rate(istio_turbo_pod_request_count{response_code="200"}[3m]) > 0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe document somewhere that the "used" query is mandatory?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

TRANSACTION:
queries:
used: 'rate(istio_turbo_pod_request_count{response_code="200"}[3m]) > 0'
attributes:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe document that every attributes section must include exactly one identifier?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

@ading1977
Copy link
Collaborator Author

Thanks for the review @dblinn. As a general comment, it is in my plan to add complete documentation and test cases in separate PRs.

@ading1977 ading1977 merged commit ed5d982 into turbonomic:master Jan 23, 2020
@ading1977 ading1977 deleted the exporter-from-config branch January 23, 2020 17:57
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

Successfully merging this pull request may close these issues.

None yet

2 participants