Help us shape the future of Go! Take the 2026 Go Developer Survey

influxdb

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

README

InfluxPi

This repository contains installation scripts for InfluxDB, Telegraf and Chronograf on the Raspian distribution for the Raspberry Pi. I guess it may work for other installations but this is the one I'm interested in. To use, the following commands can be executed:

bash% script/download-install-influxdb.sh
bash% script/download-install-chronograf.sh
bash% script/download-install-telegraf.sh

For all the scripts, you can use the -f flag to remove older versions of software and/or the -u <username> flag to indicate the user under which the database should run as, with a default of 'influxdb'. You should use the same username for all packages. The various defaults within the script can be changed. They are:

You will need to enable the services if you want them to continue running on reboot:

bash% sudo systemctl enable influxdb
bash% sudo systemctl enable telegraf
bash% sudo systemctl enable chronograf

If you then want to run the command-line client, then you can add the following line to your ~/.bash_profile

  # influxdb
  export INFLUXDB="/opt/influxdb"
  export PATH="${PATH}:${INFLUXDB}/usr/bin"

License

Copyright 2017-2018 David Thorpe

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Documentation

Overview

InfluxDB client (c) Copyright David Thorpe 2017 All Rights Reserved

For Licensing and Usage information, please see LICENSE file

InfluxDB client (c) Copyright David Thorpe 2017 All Rights Reserved

For Licensing and Usage information, please see LICENSE file

Index

Constants

View Source
const (
	// Precision defines the precision used for time values on inserting
	// data and returning it
	PRECISION_NANO    string = "ns"
	PRECISION_MICRO   string = "µ"
	PRECISION_MICRO2  string = "u"
	PRECISION_MILLI   string = "ms"
	PRECISION_SECOND  string = "s"
	PRECISION_MINUTE  string = "m"
	PRECISION_HOUR    string = "h"
	PRECISION_DAY     string = "d"
	PRECISION_WEEK    string = "w"
	PRECISION_DEFAULT string = PRECISION_MILLI
)
View Source
const (
	// DefaultPortHTTP defines the default InfluxDB port used for HTTP
	DefaultPortHTTP uint = 8086
)

Variables

View Source
var (
	// ErrNotConnected is returned when database is not connected (Close has been called)
	ErrNotConnected = errors.New("Not connected")

	// ErrNotFound is returned when something expected is not found
	ErrNotFound = errors.New("Not Found")

	// ErrAlreadyExists is returned when something already exists
	ErrAlreadyExists = errors.New("Already Exists")

	// ErrUnexpectedResponse is returned when server does not return with expected data
	ErrUnexpectedResponse = errors.New("Unexpected response from server")

	// ErrEmptyResponse is returned when response does not contain any data
	ErrEmptyResponse = errors.New("Empty response from server")

	// ErrBadParameter is returned when some calling parameter is invalid
	ErrBadParameter = errors.New("Bad Parameter")

	// ErrNotSupported is returned if a feature is not yet supported
	ErrNotSupported = errors.New("Not supported")
)

Functions

func Quote

func Quote(value string) string

Quote returns a query-safe version of an identifier (a database, series or measurement name)

func QuoteString

func QuoteString(value string) string

Returns a version of the string which has double-quotes around it, and will replace baskslashes with double backslashes and double quotes with backslash + double quote

Types

type Client

type Client interface {
	gopi.Driver

	// Get and set parameters
	Version() string
	Database() string
	SetDatabase(value string) error
	Precision() string
	SetPrecision(value string) error

	// Convenience methods for database and retention policy
	CreateDatabase(name string, policy *RetentionPolicy) error
	CreateRetentionPolicy(name string, policy *RetentionPolicy) error
	DropDatabase(name string) error
	DropRetentionPolicy(name string) error
	RetentionPolicies() (map[string]*RetentionPolicy, error)

	// Excute a query
	Do(query Query) (Results, error)

	// Return an empty dataset and write data
	NewDataset(name string, tags, fields []string) (Dataset, error)
	Write(Dataset) error
}

Client is the abstract driver interface

type Dataset

type Dataset interface {
	// Dataset read operations
	Tags() []string
	Tag(key string) string
	Fields() []string
	Len() uint
	Name() string
	Partial() bool
	ValuesAtIndex(uint) (time.Time, []Value)

	// Dataset write operations
	SetTag(key, value string)
	AddValues(values ...Value) error
	AddValuesForTimestamp(ts time.Time, values ...Value) error
}

Dataset is an abstract set of data which is written or read from the database

type Measurement

type Measurement struct {
	Name     string
	Database string
	Policy   string
}

Measurement defines a measurement

func (Measurement) String

func (m Measurement) String() string

type Predicate

type Predicate interface {
	// Return the predicate as a string
	String() string
}

Predicate is an abstract predicate (a tag, a field or a function)

func TagEquals

func TagEquals(name string, value ...string) Predicate

func TagMatches

func TagMatches(name, regexp string) Predicate

func TagNotEquals

func TagNotEquals(name, value string) Predicate

type Query

type Query interface {
	// Set parameters
	Database(value string) Query
	RetentionPolicy(value *RetentionPolicy) Query
	Default(value bool) Query
	Measurement(values ...*Measurement) Query
	OffsetLimit(offset uint, limit uint) Query
	Filter(values ...Predicate) Query

	// Return the query as a string
	String() string
}

Query is the abstract InfluxQL statement interface

func AlterRetentionPolicy

func AlterRetentionPolicy(database string, name string, policy *RetentionPolicy) Query

func CreateDatabase

func CreateDatabase(name string) Query

func CreateRetentionPolicy

func CreateRetentionPolicy(database string, name string, policy *RetentionPolicy) Query

func DropDatabase

func DropDatabase(name string) Query

func DropRetentionPolicy

func DropRetentionPolicy(database string, name string) Query

func Select

func Select(measurements ...*Measurement) Query

func ShowDatabases

func ShowDatabases() Query

func ShowMeasurements

func ShowMeasurements() Query

func ShowRetentionPolicies

func ShowRetentionPolicies() Query

func ShowSeries

func ShowSeries() Query

type Result

type Result struct {
	Result  int
	Series  int
	Name    string
	Tags    map[string]string
	Columns []string
	Values  [][]interface{}
	Partial bool
}

Result reflects the influxdb model.Row structure but which defines a number of additional methods

func (*Result) ParseRetentionPolicies

func (r *Result) ParseRetentionPolicies() (map[string]*RetentionPolicy, error)

ParseRetentionPolicies returns retention policies from a server response

func (*Result) String

func (r *Result) String() string

type Results

type Results []*Result

Results is a set of results (usually one, but may be more if more than one measure is selected)

func (Results) Column

func (r Results) Column(result int, series string, column string) ([]Value, error)

Return column values for a particular series of values for a particular query result. When using single statements, the result parameter should be zero

func (Results) String

func (r Results) String() string

type RetentionPolicy

type RetentionPolicy struct {
	Duration           time.Duration
	ShardGroupDuration time.Duration
	ReplicationFactor  int
	Default            bool
}

RetentionPolicy defines a period of time to store measurement data for

func (*RetentionPolicy) String

func (this *RetentionPolicy) String() string

type Value

type Value interface{}

Value is a value returned by influxdb

Directories

Path Synopsis
cmd
InfluxDB command-line tool
InfluxDB command-line tool
InfluxDB client (c) Copyright David Thorpe 2017 All Rights Reserved For Licensing and Usage information, please see LICENSE file
InfluxDB client (c) Copyright David Thorpe 2017 All Rights Reserved For Licensing and Usage information, please see LICENSE file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL