Skip to content

Commit

Permalink
Initial Commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
pwillie committed Dec 1, 2017
0 parents commit 3c8c6a3
Show file tree
Hide file tree
Showing 15 changed files with 942 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin
vendor
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: go

go:
- 1.8.x
- master

install:
- go get -v github.com/Masterminds/glide
- make get-deps
9 changes: 9 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Credits

## Development Lead

- Peter Wilson [pwillie](https://github.com/pwillie)

## Contributors

None yet. Why not be the first?
81 changes: 81 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

## Types of Contributions

### Report Bugs

Report bugs at https://github.com/pwillie/prometheus-es-adapter/issues.

If you are reporting a bug, please include:

* Your operating system name and version.
* Any details about your local setup that might be helpful in troubleshooting.
* Detailed steps to reproduce the bug.

### Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with "bug"
is open to whoever wants to implement it.

### Implement Features

Look through the GitHub issues for features. Anything tagged with "feature"
is open to whoever wants to implement it.

### Write Documentation

prometheus-es-adapter could always use more documentation, whether as part of the
official prometheus-es-adapter docs, in docstrings, or even on the web in blog posts,
articles, and such.

### Submit Feedback

The best way to send feedback is to file an issue at https://github.com/pwillie/prometheus-es-adapter/issues.

If you are proposing a feature:

* Explain in detail how it would work.
* Keep the scope as narrow as possible, to make it easier to implement.
* Remember that this is a volunteer-driven project, and that contributions
are welcome :)

## Get Started!

Ready to contribute? Here's how to set up `prometheus-es-adapter` for local development.

1. Fork the `prometheus-es-adapter` repo on GitHub.
2. Clone your fork locally::

$ git clone [email protected]:your_name_here/prometheus-es-adapter.git

3. Create a branch for local development::

$ git checkout -b name-of-your-bugfix-or-feature

Now you can make your changes locally.

4. When you're done making changes, check that your changes pass the tests::

$ make test

6. Commit your changes and push your branch to GitHub::

$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature

7. Submit a pull request through the GitHub website.

Pull Request Guidelines
-----------------------

Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.md.
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Build Stage
FROM golang:alpine AS build-stage

LABEL app="build-prometheus-es-adapter"
LABEL REPO="https://github.com/pwillie/prometheus-es-adapter"

ENV GOROOT=/usr/local/go \
GOPATH=/gopath \
GOBIN=/gopath/bin \
PROJPATH=/gopath/src/github.com/pwillie/prometheus-es-adapter

RUN apk add -U --no-progress build-base git

ADD . /gopath/src/github.com/pwillie/prometheus-es-adapter
WORKDIR /gopath/src/github.com/pwillie/prometheus-es-adapter

RUN make build-alpine

# Final Stage
FROM alpine:latest

ARG GIT_COMMIT
ARG VERSION
LABEL REPO="https://github.com/pwillie/prometheus-es-adapter"
LABEL GIT_COMMIT=$GIT_COMMIT
LABEL VERSION=$VERSION

# Because of https://github.com/docker/docker/issues/14914
ENV PATH=$PATH:/opt/prometheus-es-adapter/bin

WORKDIR /opt/prometheus-es-adapter/bin

COPY --from=build-stage /gopath/src/github.com/pwillie/prometheus-es-adapter/bin/prometheus-es-adapter /opt/prometheus-es-adapter/bin/
RUN chmod +x /opt/prometheus-es-adapter/bin/prometheus-es-adapter

CMD /opt/prometheus-es-adapter/bin/prometheus-es-adapter
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.PHONY: build build-alpine clean test help default

BIN_NAME=prometheus-es-adapter

VERSION := $(shell grep "const Version " version.go | sed -E 's/.*"(.+)"$$/\1/')
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
IMAGE_NAME := "pwillie/prometheus-es-adapter"

default: test

help:
@echo 'Management commands for prometheus-es-adapter:'
@echo
@echo 'Usage:'
@echo ' make build Compile the project.'
@echo ' make get-deps runs glide install, mostly used for ci.'
@echo ' make build-alpine Compile optimized for alpine linux.'
@echo ' make package Build final docker image with just the go binary inside'
@echo ' make tag Tag image created by package with latest, git commit and version'
@echo ' make test Run tests on a compiled project.'
@echo ' make push Push tagged images to registry'
@echo ' make clean Clean the directory tree.'
@echo

build:
@echo "building ${BIN_NAME} ${VERSION}"
@echo "GOPATH=${GOPATH}"
go build -ldflags "-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X main.VersionPrerelease=DEV" -o bin/${BIN_NAME}

get-deps:
glide install

build-alpine:
@echo "building ${BIN_NAME} ${VERSION}"
@echo "GOPATH=${GOPATH}"
go build -ldflags '-w -linkmode external -extldflags "-static" -X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X main.VersionPrerelease=VersionPrerelease=RC' -o bin/${BIN_NAME}

package:
@echo "building image ${BIN_NAME} ${VERSION} $(GIT_COMMIT)"
docker build --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=$(GIT_COMMIT) -t $(IMAGE_NAME):local .

tag:
@echo "Tagging: latest ${VERSION} $(GIT_COMMIT)"
docker tag $(IMAGE_NAME):local $(IMAGE_NAME):$(GIT_COMMIT)
docker tag $(IMAGE_NAME):local $(IMAGE_NAME):${VERSION}
docker tag $(IMAGE_NAME):local $(IMAGE_NAME):latest

push: tag
@echo "Pushing docker image to registry: latest ${VERSION} $(GIT_COMMIT)"
docker push $(IMAGE_NAME):$(GIT_COMMIT)
docker push $(IMAGE_NAME):${VERSION}
docker push $(IMAGE_NAME):latest

clean:
@test ! -e bin/${BIN_NAME} || rm bin/${BIN_NAME}

test:
go test $(glide nv)

18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# prometheus-es-adapter

A read and write adapter for prometheus persistent storage

## Getting started

This project requires Go to be installed. On OS X with Homebrew you can just run `brew install go`.

Running it then should be as simple as:

```console
$ make
$ ./bin/prometheus-es-adapter
```

### Testing

``make test``
39 changes: 39 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: '3.3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.0.0
ports:
- '9200:9200'
- '9300:9300'
environment:
ES_NODE_NAME: elasticsearch
XPACK_MONITORING_ENABLED: 'false'
XPACK_SECURITY_ENABLED: 'false'
discovery.type: single-node

ui-cerebro:
image: ludekvesely/elasticsearch-cerebro
links:
- elasticsearch
ports:
- '9000:9000'
environment:
ELASTICSEARCH_HOST: http://elasticsearch:9200

kibana:
image: docker.elastic.co/kibana/kibana:6.0.0
links:
- elasticsearch
ports:
- '5601:5601'
environment:
ELASTICSEARCH_URL: http://elasticsearch:9200

prometheus:
image: prom/prometheus
ports:
- '9090:9090'
# command: '--storage.tsdb.retention=10m'
# command: '-h'
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
110 changes: 110 additions & 0 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package: github.com/pwillie/prometheus-es-adapter
import:
- package: gopkg.in/olivere/elastic.v5
- package: github.com/davecgh/go-spew
subpackages:
- spew
- package: github.com/google/uuid
- package: github.com/namsral/flag
Loading

0 comments on commit 3c8c6a3

Please sign in to comment.