说明文档来自官方文档 https://checkr.github.io/flagr/#/flagr_env

完整配置

包含了组件的配置参数以及说明,对于学习如何使用Flagr 还是很重要的,包含了数据库配置、jwt 安全配置、Flagr metrics 配置(对应的Recorder)
目前是kafaka 配置,同时也内置了prometheus 的配置参数,以及一些常用监控工具的指标暴露。

package config

import "time"

// Config is the whole configuration of the app
var Config = struct {
// Host - Flagr server host
Host string `env:"HOST" envDefault:"localhost"`
// Port - Flagr server port
Port int `env:"PORT" envDefault:"18000"` // LogrusLevel sets the logrus logging level
LogrusLevel string `env:"FLAGR_LOGRUS_LEVEL" envDefault:"info"`
// PProfEnabled - to enable the standard pprof of golang's http server
PProfEnabled bool `env:"FLAGR_PPROF_ENABLED" envDefault:"true"` // MiddlewareVerboseLoggerEnabled - to enable the negroni-logrus logger for all the endpoints useful for debugging
MiddlewareVerboseLoggerEnabled bool `env:"FLAGR_MIDDLEWARE_VERBOSE_LOGGER_ENABLED" envDefault:"true"`
// MiddlewareGzipEnabled - to enable gzip middleware
MiddlewareGzipEnabled bool `env:"FLAGR_MIDDLEWARE_GZIP_ENABLED" envDefault:"true"` // RateLimiterPerFlagPerSecondConsoleLogging - to rate limit the logging rate
// per flag per second
RateLimiterPerFlagPerSecondConsoleLogging int `env:"FLAGR_RATELIMITER_PERFLAG_PERSECOND_CONSOLE_LOGGING" envDefault:"100"` // EvalEnableDebug - controls if we want to return evaluation debugging information back to the api requests
// Note that this is a global switch:
// if it's disabled, no evaluation debug info will be returned.
// if it's enabled, it respects evaluation request's enableDebug field
EvalDebugEnabled bool `env:"FLAGR_EVAL_DEBUG_ENABLED" envDefault:"true"`
// EvalLoggingEnabled - to enable the logging for eval results
EvalLoggingEnabled bool `env:"FLAGR_EVAL_LOGGING_ENABLED" envDefault:"true"`
// EvalCacheRefreshTimeout - timeout of getting the flags data from DB into the in-memory evaluation cache
EvalCacheRefreshTimeout time.Duration `env:"FLAGR_EVALCACHE_REFRESHTIMEOUT" envDefault:"59s"`
// EvalCacheRefreshInterval - time interval of getting the flags data from DB into the in-memory evaluation cache
EvalCacheRefreshInterval time.Duration `env:"FLAGR_EVALCACHE_REFRESHINTERVAL" envDefault:"3s"`
// EvalOnlyMode - will only expose the evaluation related endpoints.
// This field will be derived from DBDriver
EvalOnlyMode bool `env:"FLAGR_EVAL_ONLY_MODE" envDefault:"false"` /**
DBDriver and DBConnectionStr define how we can write and read flags data.
For databases, flagr supports sqlite3, mysql and postgres.
For read-only evaluation, flagr supports file and http. Examples: FLAGR_DB_DBDRIVER FLAGR_DB_DBCONNECTIONSTR
================= ===============================================================
"sqlite3" "/tmp/file.db"
"sqlite3" ":memory:"
"mysql" "root:@tcp(127.0.0.1:18100)/flagr?parseTime=true"
"postgres" "host=myhost user=root dbname=flagr password=mypassword" "json_file" "/tmp/flags.json" # (it automatically sets EvalOnlyMode=true)
"json_http" "https://example.com/flags.json" # (it automatically sets EvalOnlyMode=true) */
DBDriver string `env:"FLAGR_DB_DBDRIVER" envDefault:"sqlite3"`
DBConnectionStr string `env:"FLAGR_DB_DBCONNECTIONSTR" envDefault:"flagr.sqlite"`
// DBConnectionDebug controls whether to show the database connection debugging logs
// warning: it may log the credentials to the stdout
DBConnectionDebug bool `env:"FLAGR_DB_DBCONNECTION_DEBUG" envDefault:"true"`
// DBConnectionRetryAttempts controls how we are going to retry on db connection when start the flagr server
DBConnectionRetryAttempts uint `env:"FLAGR_DB_DBCONNECTION_RETRY_ATTEMPTS" envDefault:"9"`
DBConnectionRetryDelay time.Duration `env:"FLAGR_DB_DBCONNECTION_RETRY_DELAY" envDefault:"100ms"` // CORSEnabled - enable CORS
CORSEnabled bool `env:"FLAGR_CORS_ENABLED" envDefault:"true"` // SentryEnabled - enable Sentry and Sentry DSN
SentryEnabled bool `env:"FLAGR_SENTRY_ENABLED" envDefault:"false"`
SentryDSN string `env:"FLAGR_SENTRY_DSN" envDefault:""` // NewRelicEnabled - enable the NewRelic monitoring for all the endpoints and DB operations
NewRelicEnabled bool `env:"FLAGR_NEWRELIC_ENABLED" envDefault:"false"`
NewRelicAppName string `env:"FLAGR_NEWRELIC_NAME" envDefault:"flagr"`
NewRelicKey string `env:"FLAGR_NEWRELIC_KEY" envDefault:""` // StatsdEnabled - enable statsd metrics for all the endpoints and DB operations
StatsdEnabled bool `env:"FLAGR_STATSD_ENABLED" envDefault:"false"`
StatsdHost string `env:"FLAGR_STATSD_HOST" envDefault:"127.0.0.1"`
StatsdPort string `env:"FLAGR_STATSD_PORT" envDefault:"8125"`
StatsdPrefix string `env:"FLAGR_STATSD_PREFIX" envDefault:"flagr."`
StatsdAPMEnabled bool `env:"FLAGR_STATSD_APM_ENABLED" envDefault:"false"`
StatsdAPMPort string `env:"FLAGR_STATSD_APM_PORT" envDefault:"8126"`
StatsdAPMServiceName string `env:"FLAGR_STATSD_APM_SERVICE_NAME" envDefault:"flagr"` // PrometheusEnabled - enable prometheus metrics export
PrometheusEnabled bool `env:"FLAGR_PROMETHEUS_ENABLED" envDefault:"false"`
// PrometheusPath - set the path on which prometheus metrics are available to scrape
PrometheusPath string `env:"FLAGR_PROMETHEUS_PATH" envDefault:"/metrics"`
// PrometheusIncludeLatencyHistogram - set whether Prometheus should also export a histogram of request latencies (this increases cardinality significantly)
PrometheusIncludeLatencyHistogram bool `env:"FLAGR_PROMETHEUS_INCLUDE_LATENCY_HISTOGRAM" envDefault:"false"` // RecorderEnabled - enable data records logging
RecorderEnabled bool `env:"FLAGR_RECORDER_ENABLED" envDefault:"false"`
// RecorderType - the pipeline to log data records, e.g. Kafka
RecorderType string `env:"FLAGR_RECORDER_TYPE" envDefault:"kafka"` /**
RecorderFrameOutputMode - indicates which data record frame output mode should we use.
Possible values: payload_string, payload_raw_json * payload_string mode:
it respects the encryption settings, and it will stringify the payload to unify
the type of the output for both plaintext and encrypted payload. {"payload":"{\"evalContext\":{\"entityID\":\"123\"},\"flagID\":1,\"flagKey\":null,\"flagSnapshotID\":1,\"segmentID\":1,\"timestamp\":null,\"variantAttachment\":null,\"variantID\":1,\"variantKey\":\"control\"}","encrypted": false} * payload_raw_json mode:
it ignores the encryption settings. {"payload":{"evalContext":{"entityID":"123"},"flagID":1,"flagKey":null,"flagSnapshotID":1,"segmentID":1,"timestamp":null,"variantAttachment":null,"variantID":1,"variantKey":"control"}}
*/
RecorderFrameOutputMode string `env:"FLAGR_RECORDER_FRAME_OUTPUT_MODE" envDefault:"payload_string"` // Kafka related configurations for data records logging (Flagr Metrics)
RecorderKafkaVersion string `env:"FLAGR_RECORDER_KAFKA_VERSION" envDefault:"0.8.2.0"`
RecorderKafkaBrokers string `env:"FLAGR_RECORDER_KAFKA_BROKERS" envDefault:":9092"`
RecorderKafkaCertFile string `env:"FLAGR_RECORDER_KAFKA_CERTFILE" envDefault:""`
RecorderKafkaKeyFile string `env:"FLAGR_RECORDER_KAFKA_KEYFILE" envDefault:""`
RecorderKafkaCAFile string `env:"FLAGR_RECORDER_KAFKA_CAFILE" envDefault:""`
RecorderKafkaVerifySSL bool `env:"FLAGR_RECORDER_KAFKA_VERIFYSSL" envDefault:"false"`
RecorderKafkaVerbose bool `env:"FLAGR_RECORDER_KAFKA_VERBOSE" envDefault:"true"`
RecorderKafkaTopic string `env:"FLAGR_RECORDER_KAFKA_TOPIC" envDefault:"flagr-records"`
RecorderKafkaRetryMax int `env:"FLAGR_RECORDER_KAFKA_RETRYMAX" envDefault:"5"`
RecorderKafkaFlushFrequency time.Duration `env:"FLAGR_RECORDER_KAFKA_FLUSHFREQUENCY" envDefault:"500ms"`
RecorderKafkaEncrypted bool `env:"FLAGR_RECORDER_KAFKA_ENCRYPTED" envDefault:"false"`
RecorderKafkaEncryptionKey string `env:"FLAGR_RECORDER_KAFKA_ENCRYPTION_KEY" envDefault:""` // Kinesis related configurations for data records logging (Flagr Metrics)
RecorderKinesisStreamName string `env:"FLAGR_RECORDER_KINESIS_STREAM_NAME" envDefault:"flagr-records"`
RecorderKinesisBacklogCount int `env:"FLAGR_RECORDER_KINESIS_BACKLOG_COUNT" envDefault:"500"`
RecorderKinesisMaxConnections int `env:"FLAGR_RECORDER_KINESIS_MAX_CONNECTIONS" envDefault:"24"`
RecorderKinesisFlushInterval time.Duration `env:"FLAGR_RECORDER_KINESIS_FLUSH_INTERVAL" envDefault:"5s"`
RecorderKinesisBatchCount int `env:"FLAGR_RECORDER_KINESIS_BATCH_COUNT" envDefault:"500"`
RecorderKinesisBatchSize int `env:"FLAGR_RECORDER_KINESIS_BATCH_SIZE" envDefault:"0"`
RecorderKinesisAggregateBatchCount int `env:"FLAGR_RECORDER_KINESIS_AGGREGATE_BATCH_COUNT" envDefault:"4294967295"`
RecorderKinesisAggregateBatchSize int `env:"FLAGR_RECORDER_KINESIS_AGGREGATE_BATCH_SIZE" envDefault:"51200"`
RecorderKinesisVerbose bool `env:"FLAGR_RECORDER_KINESIS_VERBOSE" envDefault:"false"` // Pubsub related configurations for data records logging (Flagr Metrics)
RecorderPubsubProjectID string `env:"FLAGR_RECORDER_PUBSUB_PROJECT_ID" envDefault:""`
RecorderPubsubTopicName string `env:"FLAGR_RECORDER_PUBSUB_TOPIC_NAME" envDefault:"flagr-records"`
RecorderPubsubKeyFile string `env:"FLAGR_RECORDER_PUBSUB_KEYFILE" envDefault:""`
RecorderPubsubVerbose bool `env:"FLAGR_RECORDER_PUBSUB_VERBOSE" envDefault:"false"`
RecorderPubsubVerboseCancelTimeout time.Duration `env:"FLAGR_RECORDER_PUBSUB_VERBOSE_CANCEL_TIMEOUT" envDefault:"5s"` /**
JWTAuthEnabled enables the JWT Auth Via Cookies:
The pattern of using JWT auth token using cookies is that it redirects to the URL to set cross subdomain cookie
For example, redirect to auth.example.com/signin, which sets Cookie access_token=jwt_token for domain
".example.com". One can also whitelist some routes so that they don't get blocked by JWT auth Via Headers:
If you wish to use JWT Auth via headers you can simply set the header `Authorization Bearer [access_token]` Supported signing methods:
* HS256, in this case `FLAGR_JWT_AUTH_SECRET` contains the passphrase
* RS256, in this case `FLAGR_JWT_AUTH_SECRET` contains the key in PEM Format Note:
If the access_token is present in both the header and cookie only the latest will be used
*/
JWTAuthEnabled bool `env:"FLAGR_JWT_AUTH_ENABLED" envDefault:"false"`
JWTAuthDebug bool `env:"FLAGR_JWT_AUTH_DEBUG" envDefault:"false"`
JWTAuthPrefixWhitelistPaths []string `env:"FLAGR_JWT_AUTH_WHITELIST_PATHS" envDefault:"/api/v1/evaluation,/static" envSeparator:","`
JWTAuthExactWhitelistPaths []string `env:"FLAGR_JWT_AUTH_EXACT_WHITELIST_PATHS" envDefault:",/" envSeparator:","`
JWTAuthCookieTokenName string `env:"FLAGR_JWT_AUTH_COOKIE_TOKEN_NAME" envDefault:"access_token"`
JWTAuthSecret string `env:"FLAGR_JWT_AUTH_SECRET" envDefault:""`
JWTAuthNoTokenStatusCode int `env:"FLAGR_JWT_AUTH_NO_TOKEN_STATUS_CODE" envDefault:"307"` // "307" or "401"
JWTAuthNoTokenRedirectURL string `env:"FLAGR_JWT_AUTH_NO_TOKEN_REDIRECT_URL" envDefault:""`
JWTAuthUserProperty string `env:"FLAGR_JWT_AUTH_USER_PROPERTY" envDefault:"flagr_user"`
// JWTAuthUserClaim can be used as the indicator of a user for created_by or updated_by.
// E.g. sub, email, user, name, and etc in a JWT token.
JWTAuthUserClaim string `env:"FLAGR_JWT_AUTH_USER_CLAIM" envDefault:"sub"` // "HS256" and "RS256" supported
JWTAuthSigningMethod string `env:"FLAGR_JWT_AUTH_SIGNING_METHOD" envDefault:"HS256"` // WebPrefix - base path for web and API
// e.g. FLAGR_WEB_PREFIX=/foo
// UI path => localhost:18000/foo"
// API path => localhost:18000/foo/api/v1"
WebPrefix string `env:"FLAGR_WEB_PREFIX" envDefault:""`
}{}

说明

从配置参数中我们可以看出功能还是很强大,类似的工具有togglzff4j

 
 
 
 

Flagr 配置说明的更多相关文章

  1. NHibernate之映射文件配置说明

    NHibernate之映射文件配置说明 1. hibernate-mapping 这个元素包括以下可选的属性.schema属性,指明了这个映射所引用的表所在的schema名称.假若指定了这个属性, 表 ...

  2. WCF服务器证书配置说明-没有能够进行密钥交换的私钥,或者进程可能没有访问私钥的权限

    WCF服务器证书配置说明 1.创建证书: makecert.exe -sr LocalMachine -ss My -a sha1 -n CN=XXX -sky exchange -pe 说明: -s ...

  3. log4net一些配置说明

    <configuration> <configSections> <section name="log4net" type="System. ...

  4. maven -- 学习笔记(二)之setting.xml配置说明(备忘)

    setting.xml配置说明,learn from:http://pengqb.javaeye.com,http://blog.csdn.net/mypop/article/details/6146 ...

  5. Atitit.mybatis的测试  以及spring与mybatis在本项目中的集成配置说明

    Atitit.mybatis的测试  以及spring与mybatis在本项目中的集成配置说明 1.1. Mybatis invoke1 1.2. Spring的数据源配置2 1.3. Mybatis ...

  6. syslog-ng 学习心得与配置说明

    配置说明syslog-ng的主配置文件存放在:/etc/syslog-ng/syslog-ng.conf 一.基础 系统自带版本: 引用 # rpm -qa|grep syslog-ng syslog ...

  7. keepalived工作原理和配置说明 腾讯云VPC内通过keepalived搭建高可用主备集群

    keepalived工作原理和配置说明 腾讯云VPC内通过keepalived搭建高可用主备集群 内网路由都用mac地址 一个mac地址绑定多个ip一个网卡只能一个mac地址,而且mac地址无法改,但 ...

  8. [Asp.net]Uploadify所有配置说明,常见bug问题分析

    引言 之前写过一篇使用swfupload上传图片的文章:周末大放送网站图片上传,水印,预览,截图,这里分析一下,当时使用uploadify上传,无法获取上传后,图片路径的问题.当时没有测试没有成功,一 ...

  9. Apache Shiro 使用手册(五)Shiro 配置说明

    Apache Shiro的配置主要分为四部分:  对象和属性的定义与配置 URL的过滤器配置 静态用户配置 静态角色配置 其中,由于用户.角色一般由后台进行操作的动态数据,因此Shiro配置一般仅包含 ...

随机推荐

  1. Java——继承的运行顺序

    首先看一个代码 父类代码: public class Parent { { System.out.println("Parent非静态代码块"); } static { Syste ...

  2. python笔记25-sys模块

    import sys#sys.argv命令行参数List,第一个元素是程序本身路径# sys.exit('xxxxx')#退出程序,正常退出时exit(0)# print(sys.version) # ...

  3. jmeter之headers中的Content-Type.

    jmeter在发送http post请求时,会把body  里的数据格式给携带上(最好携带上),一般在信息头里增加.另因一篇文章.感觉写的非常好.https://imququ.com/post/fou ...

  4. Ubuntu16.04安装MongoDB的Ruby驱动

    背景: 1. ruby的安装方式:sudo apt-get install ruby 2. mongod服务已开启 3. ruby版本:2.3, gem已安装 安装驱动的步骤: 1. gem inst ...

  5. 基于IntelliJ IDEA开发工具搭建SSM框架并实现页面登录功能详细讲解二

    接: 接下来配置类 UserController package com.chatRotbot.controller; import com.chatRotbot.model.User; import ...

  6. day16 面向对象二

    类的成员之变量 1. 实例变量. 对象.xxx = xxx 2. 类变量. 直接写在类中的变量就是类变量. 类变量一般用类名来访问. 对象中共性的属性提取出来. 例: class A: a = 1 # ...

  7. 【转】Android-Input 按键字符映射文件&输入设备配置文件

    https://source.android.com/devices/input/key-character-map-files 按键字符映射文件 按键字符映射文件(.kcm 文件)负责将 Andro ...

  8. Android作业

    一.设置跑马灯功能   使用滚动字幕显示标题“请选择你喜欢哪种花” <?xml version="1.0" encoding="utf-8"?>&l ...

  9. ivew Tooltip

    在使用ivew的Tooltip时发生错位,添加属性transfer,避免受父样式影响 发生如上错误时,只需添加属性transfer无需赋值

  10. java实现截图功能

    package Jietu; import java.awt.Dimension; import java.awt.Rectangle; import java.awt.Robot; import j ...