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

[mysqld-mixin] How do we use it as a library? #518

Open
sdurrheimer opened this issue Dec 4, 2020 · 1 comment · May be fixed by #935
Open

[mysqld-mixin] How do we use it as a library? #518

sdurrheimer opened this issue Dec 4, 2020 · 1 comment · May be fixed by #935

Comments

@sdurrheimer
Copy link
Contributor

sdurrheimer commented Dec 4, 2020

Is there a way to properly use the mysqld-mixin/mixin.libsonnet to import rules and alerts?

For example with prometheus/kube-prometheus, I was trying to do:

local thanosMixin = import 'thanos-mixin/mixin.libsonnet';
local corednsMixin = import 'coredns-mixin/mixin.libsonnet';
local certManagerMixin = import 'cert-manager-mixin/mixin.libsonnet';

// trying to use mysqld-mixin the same way as others
local mysqldMixin = import 'mysqld-mixin/mixin.libsonnet';

local kp =
  (import 'kube-prometheus/kube-prometheus.libsonnet') +
  (import 'thanos-mixin/config.libsonnet') +
  {
    _config+:: {
      namespace: 'monitoring',
    },
    prometheusRules+::
      thanosMixin.prometheusRules +
      certManagerMixin.prometheusRules +
      // trying to use mysqld-mixin the same way as others
      mysqldMixin.prometheusRules +
      {
        // groups+: [],
      },
    prometheusAlerts+:: 
      thanosMixin.prometheusAlerts +
      corednsMixin.prometheusAlerts +
      certManagerMixin.prometheusAlerts +
      // trying to use mysqld-mixin the same way as others
      mysqldMixin.prometheusAlerts +
      {
        // cat existingrule.yaml | gojsontoyaml -yamltojson > existingrule.json
        // groups+: (import 'existingrule.json').groups,
      },
  }

But I end up with the following error:

+ jsonnet -J vendor -m manifests kube-prometheus.jsonnet
+ xargs '-I{}' sh -c 'cat {} | gojsontoyaml > {}.yaml' -- '{}'
RUNTIME ERROR: only functions can be called, got null
	vendor/mysqld-mixin/mixin.libsonnet:9:14-44	object <anonymous>
@ngclinflows
Copy link

It's been a while, but also facing the same problem while using go-jsonnet instead of mixtool which provides Tanka native functions on top of standard jsonnet.

I guess mysqld-mixin chose to use parseYaml native function when it was not available to standard jsonnet implementation, but since jsonnet standard library provides parseYaml since some time, why not using it?

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 a pull request may close this issue.

2 participants