Skip to content

A simple exmaple of prometheus exporter for learning how to writing a prometheus exporter.

Notifications You must be signed in to change notification settings

del680202/dummy_exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project is a simple exmaple of prometheus exporter for learning how to writing a prometheus exporter.

And it also is a example project for practicing Golang project.

Prepare

First, install go in your environment

Setup GO environment

$ mkdir -p $HOME/golang

$ export GOROOT=/usr/local/go  # Choose your go installed directory
$ export GOPATH=$HOME/golang
$ export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Deploy

Deploy from github

$ USER_NAME=del680202
$ mkdir -p $GOPATH/src/github.com/$USER_NAME
$ cd $GOPATH/src/github.com/$USER_NAME
$ git clone https://github.com/del680202/dummy_exporter.git
$ cd dummy_exporter/

Deplo by manual

# Make project folder, the format is $GOPATH/src/github.com/USER_NAME/PROJECT_NAME, using it to bind github
$ USER_NAME=del680202
$ PROJECT_NAME=dummy_exporter
$ mkdir -p $GOPATH/src/github.com/$USER_NAME/$PROJECT_NAME
$ cd $GOPATH/src/github.com/$USER_NAME/$PROJECT_NAME

# Install dep to handle dependency
$ go get -v github.com/golang/dep
$ go install -v github.com/golang/dep/cmd/dep

# Init. it will create vendor,Gopkg.toml,Gopkg.lock on your proejct folder
dep init

# Edit main.go as this site
$ vim main.go

# Install dependency
$ dep ensure
# or
$ dep ensure -v

Test Run

$ go run main.go

Build & Run

$ go build
$ ./dummy_exporter

When you run dummy_exporter, you can access http://127.0.0.1:8081 to see result

And you can see result as below:

# HELP dummy_gauge_metric This is a dummy gauge metric
# TYPE dummy_gauge_metric gauge
dummy_gauge_metric 0
# HELP dummy_gauge_vec_metric This is a dummy gauga vece metric
# TYPE dummy_gauge_vec_metric gauge
dummy_gauge_vec_metric{myLabel="hello"} 0
...

Push Project to Github (Option)

If you deploy this project by manual, you can push it back to github by

  1. Create a PROJECT in github
  2. Type command as below
$ git init
$ git add .
$ git commit -m "first commit"
$ git remote add origin https://github.com/$USER_NAME/$PROJECT_NAME.git
$ git push -u origin master

About

A simple exmaple of prometheus exporter for learning how to writing a prometheus exporter.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages