monitor

package
v1.0.6-0...-83bb905 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2020 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

  • Copyright 2018 Information Systems Engineering, TU Berlin, Germany *
  • 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. *
  • This is being developed for the DITAS Project: https://www.ditas-project.eu/

DEPRECATED

  • Copyright 2018 Information Systems Engineering, TU Berlin, Germany *

  • 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. *

  • This is being developed for the DITAS Project: https://www.ditas-project.eu/

  • Copyright 2018 Information Systems Engineering, TU Berlin, Germany *

  • 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. *

  • This is being developed for the DITAS Project: https://www.ditas-project.eu/

Index

Constants

View Source
const BufferSize = 100

Variables

This section is empty.

Functions

func NewIAM

func NewIAM(conf Configuration) *iam

func SetLog

func SetLog(entty *logrus.Entry)

func SetLogger

func SetLogger(nLogger *logrus.Logger)

Types

type BufferedExchangeReporter

type BufferedExchangeReporter struct {
	Buffer           *MessageBuffer
	ExchangeEndpoint string
}

func NewBufferedExchangeReporter

func NewBufferedExchangeReporter(ExchangeEndpoint string) (*BufferedExchangeReporter, error)

NewExchangeReporter creates a new exchange worker

func (*BufferedExchangeReporter) Add

func (er *BufferedExchangeReporter) Add(message ExchangeMessage)

func (*BufferedExchangeReporter) Dump

func (er *BufferedExchangeReporter) Dump() []byte

func (*BufferedExchangeReporter) Start

func (er *BufferedExchangeReporter) Start()

Start will create a new worker process, for processing exchange Messages

func (*BufferedExchangeReporter) Stop

func (er *BufferedExchangeReporter) Stop()

Stop will terminate any running worker process

type Configuration

type Configuration struct {
	Endpoint string // the endpoint that all requests are send to

	ElasticSearchURL string //eleasticSerach endpoint

	ElasticBasicAuth bool //if active we use basic auth
	ElasticUser      string
	ElasticPassword  string

	CertificateLocation string //the location certificates are read/written

	TombstoneSecret        string // the preshared secret that is used to sign tombstone commands
	InjectTombstoneHeader  bool
	TombstoneHeader        map[string]string
	ViolentConnectionDeath bool

	VDCName string // VDCName (used for the index name in elastic serach)

	VDCID       string
	BlueprintID string

	Opentracing    bool   //tells the proxy if a tracing header should be injected
	ZipkinEndpoint string //zipkin endpoint

	UseACME       bool //if true the proxy will aquire a LetsEncrypt certificate for the SSL connection
	UseSelfSigned bool //if UseACME is false, the proxy can use self signed certificates

	ForwardTraffic      bool //if true all traffic is forwareded to the exchangeReporter
	ExchangeReporterURL string
	ExchangeSecret      string

	UseIAM      bool   //if true, authentication is required for all requests
	KeyCloakURL string // url for keycloak

	IAMURL  string //deprecated
	JWKSURL string //deprecated

	BenchmarkForward bool
	BMSURL           string //PayloadGenerator URL

	IgnoreElastic bool

	Strict bool //enforce routing in blueprint

	Port    int
	SSLPort int

	InfrastructureID string //Infrastructure ID

	DemoMode               bool
	DemoSecret             string // the preshared secret that is used to activate perform demo
	SimulateInfrastructure bool

	DANGERZONE bool // disable all authentication on the control plane also autoallow all login. This is the Danger Zone do not use in production ever!
	// contains filtered or unexported fields
}

type DITASClaims

type DITASClaims struct {
	*jwt.StandardClaims
	Relams map[string][]string `json:"realm_access"`
	User   string              `json:"preferred_username"`
}

TODO switch to "github.com/gbrlsnchs/jwt/v3"

type ElasticReporter

type ElasticReporter struct {
	Queue    chan MeterMessage
	Client   *elastic.Client
	VDCName  string
	QuitChan chan bool
	// contains filtered or unexported fields
}

func NewElasticReporter

func NewElasticReporter(config Configuration, queue chan MeterMessage) (ElasticReporter, error)

NewElasticReporter creates a new reporter worker, will fail if no elastic client can be built otherwise retunrs a worker handler

func (*ElasticReporter) Start

func (er *ElasticReporter) Start()

TODO: XXX needs testing Start creates a new worker process and waits for meterMessages can only be terminated by calling Stop()

func (*ElasticReporter) Stop

func (er *ElasticReporter) Stop()

Stop termintates this Worker

type ExchangeAgent

type ExchangeAgent interface {
	Start()
	Stop()
	Add(ExchangeMessage)
	Dump() []byte
}

type ExchangeMessage

type ExchangeMessage struct {
	MeterMessage
	RequestID   string    `json:"id"`
	VDCID       string    `json:"vdcid"`
	BlueprintID string    `json:"bpid"`
	Timestamp   time.Time `json:"@timestamp"`

	RequestBody   string      `json:"request.body,omitempty"`
	RequestHeader http.Header `json:"request.header,omitempty"`

	ResponseBody   string      `json:"response.body,omitempty"`
	ResponseHeader http.Header `json:"response.header,omitempty"`
	// contains filtered or unexported fields
}

type ExchangeReporter

type ExchangeReporter struct {
	Queue            chan ExchangeMessage
	ExchangeEndpoint string
	QuitChan         chan bool
}

func NewExchangeReporter

func NewExchangeReporter(ExchangeEndpoint string) (*ExchangeReporter, error)

NewExchangeReporter creates a new exchange worker

func (*ExchangeReporter) Add

func (er *ExchangeReporter) Add(message ExchangeMessage)

func (*ExchangeReporter) Dump

func (er *ExchangeReporter) Dump() []byte

func (*ExchangeReporter) Start

func (er *ExchangeReporter) Start()

Start will create a new worker process, for processing exchange Messages

func (*ExchangeReporter) Stop

func (er *ExchangeReporter) Stop()

Stop will terminate any running worker process

type MessageBuffer

type MessageBuffer struct {
	// contains filtered or unexported fields
}

func NewMessageBuffer

func NewMessageBuffer() *MessageBuffer

func (*MessageBuffer) Add

func (buffer *MessageBuffer) Add(message ExchangeMessage)

func (*MessageBuffer) AsSlice

func (buffer *MessageBuffer) AsSlice() []ExchangeMessage

func (*MessageBuffer) Clear

func (buffer *MessageBuffer) Clear()

type MeterMessage

type MeterMessage struct {
	RequestID   string `json:"request.id"`
	BlueprintID string `json:"request.blueprintID"`
	OperationID string `json:"request.operationID"`

	Timestamp     time.Time     `json:"@timestamp"`
	RequestLenght int64         `json:"request.length"`
	Kind          string        `json:"request.method,omitempty"`
	Client        string        `json:"request.client,omitempty"`
	Method        string        `json:"request.path,omitempty"`
	RequestTime   time.Duration `json:"request.requestTime"`

	ResponseCode   int   `json:"response.code,omitempty"`
	ResponseStatus int   `json:"response.status,omitempty"`
	ResponseLength int64 `json:"response.length,omitempty"`
}

type RequestMonitor

type RequestMonitor struct {
	// contains filtered or unexported fields
}

RequestMonitor data struct

func NewManger

func NewManger() (*RequestMonitor, error)

NewManger Creates a new logging, tracing RequestMonitor

func (*RequestMonitor) AddCircuit

func (mon *RequestMonitor) AddCircuit(listener *circuitBreakingListener)

func (*RequestMonitor) Authenticate

func (mon *RequestMonitor) Authenticate(req *http.Request, secret *jwt.HMACSHA) error

func (*RequestMonitor) Listen

func (mon *RequestMonitor) Listen()

Listen will start all worker threads and wait for incoming requests

func (*RequestMonitor) OptainLatesIAMKey

func (mon *RequestMonitor) OptainLatesIAMKey(token *jwt.Token) (interface{}, error)

type ResouceCache

type ResouceCache struct {
	// contains filtered or unexported fields
}

func NewResourceCache

func NewResourceCache(blueprint *spec.Blueprint) ResouceCache

func (*ResouceCache) Add

func (rc *ResouceCache) Add(path string, method string, operationID string)

func (*ResouceCache) Contains

func (rc *ResouceCache) Contains(path string) bool

func (*ResouceCache) Get

func (rc *ResouceCache) Get(path string, method string) (string, bool)

func (*ResouceCache) Match

func (rc *ResouceCache) Match(path string, method string) (string, error)

type TokenContext

type TokenContext struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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