Giter Site home page Giter Site logo

grafana-export's Introduction

Grafana Export

Grafana exporter is a modified csv exporter that outputs csv data in a format that works well with csv import into Grafana dashboards.

Parameters

Plugin config

Required fields:

  • output-path: The full file path to write the exported csv file.

Optional fields:

  • headers: A list of headers to extract from the inputs to write as columns in the csv file. An empty list of headers will write all fields provided as inputs to the pluginParams. The default list of headers is empty therefore all input data will be written to the csv file.

Inputs

The inputs should be in the standard format provided by the IF project.

Outputs

This plugin will write externally to disk as csv file and pass the inputs directly as output.

Implementation

To run the plugin, you must first create an instance of GrafanaExport and call its execute() function with the desired inputs.

Usage

To run the grafana-export, an instance of PluginInterface must be created. Then, the plugin's execute() method can be called, passing required arguments to it.

This is how you could run the model in Typescript:

async function runPlugin() {
    const newPlugin = GrafanaExport();
    const usage = await newPlugin.execute([
        {
            timestamp: '2023-07-06T00:00',
            duration: 1,
            'operational-carbon': 0.02,
            'carbon-embodied': 5,
            energy: 3.5,
            carbon: 5.02,
        },
    ]);

    console.log(usage);
}

runPlugin();

Testing model integration

Using local links

For using locally developed model in IF Framework please follow these steps:

  1. On the root level of a locally developed model run npm link, which will create global package. It uses package.json file's name field as a package name. Additionally name can be checked by running npm ls -g --depth=0 --link=true.
  2. Use the linked model in impl by specifying name, method, path in initialize models section.
name: grafana-export-demo
description: example exporting output to a csv file
tags:
initialize:
  outputs:
    - yaml
  plugins:
    grafana-exporter:
      method: GrafanaExport
      path: 'grafana-export'
tree:
  children:
    child:
      pipeline:
        - grafana-exporter
      config:
        grafana-exporter:
          output-path: C:/dev/grafana-export.csv
          headers:
            - timestamp
            - duration
            - carbon
            - energy
      inputs:
        - timestamp: 2023-07-06T00:00
          duration: 1
          carbon-operational: 0.02
          carbon-embodied: 5
          energy: 3.5
          carbon: 5.02
        - timestamp: 2023-07-06T00:10
          duration: 1
          operational-carbon: 0.03
          carbon-embodied: 4
          energy: 2.9
          carbon: 4.03

Using directly from Github

You can simply push your model to the public Github repository and pass the path to it in your impl. For example, for a model saved in github.com/perkss/grafana-export you can do the following:

npm install your model:

npm install -g https://github.com/perkss/grafana-export

Then, in your impl, provide the path in the model instantiation. You also need to specify which class the model instantiates. In this case you are using the PluginInterface, so you can specify OutputModel.

name: grafana-export-demo
description: example exporting output to a csv file
tags:
initialize:
  outputs:
    - yaml
  plugins:
    grafana-exporter:
      method: GrafanaExport
      path: https://github.com/perkss/grafana-export
tree:
  children:
    child:
      pipeline:
        - grafana-exporter
      config:
        grafana-exporter:
          output-path: C:/dev/grafana-export.csv
          headers:
            - timestamp
            - duration
            - carbon
            - energy
      inputs:
        - timestamp: 2023-07-06T00:00
          duration: 1
          carbon-operational: 0.02
          carbon-embodied: 5
          energy: 3.5
          carbon: 5.02
        - timestamp: 2023-07-06T00:10
          duration: 1
          operational-carbon: 0.03
          carbon-embodied: 4
          energy: 2.9
          carbon: 4.03

Now, when you run the manifest using the IF CLI, it will load the model automatically. Run using:

ie --manifest <path-to-your-impl> --output <path-to-save-output>

grafana-export's People

Contributors

perkss avatar

Stargazers

 avatar

Watchers

 avatar

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.