Export custom collectd PostgreSQL metrics to GCP Stackdriver Monitoring - stackdriver

Background
I'm trying to export PostgreSQL replication delay by adding a custom <Query>
statement to my PostgreSQL config (original config from Stackdriver PostgreSQL
Plugin) in
stackdriver-agents collectd configuration
directory.
/opt/stackdriver/collectd/etc/postgresql.conf:
# This is the monitoring configuration for PostgreSQL.
# Make sure the statistics collector is enabled in your PostgreSQL configuration.
# NOTE: This configuration needs to be hand-edited in order to work.
# Look for DATABASE_NAME, STATS_USER, STATS_PASS, POSTGRESQL_HOST and POSTGRESQL_PORT to adjust your configuration file.
LoadPlugin postgresql
<Plugin "postgresql">
<Query replication_lag_seconds>
Statement "SELECT (CASE WHEN pg_last_xlog_receive_location() = pg_last_xlog_replay_location() THEN 0 ELSE EXTRACT (EPOCH FROM now() - pg_last_xact_replay_timestamp()) END) AS log_delay"
<Result>
Type "gauge"
ValuesFrom "log_delay"
</Result>
</Query>
# Each database needs a separate Database section.
# Replace DATABASE_NAME in the Database section with the name of the database.
<Database "THE_DATABASE">
# Host and port are only used for TCP/IP connections.
# Leaving them out indicates you wish to connect via domain sockets.
# When using non-standard PostgreSQL configurations, replace the below with
Host "localhost"
Port "5432"
User "THE_USER"
Password "hunter2"
Query backends
Query transactions
Query queries
Query table_states
Query disk_io
Query disk_usage
Query replication_lag_seconds # My custom query
</Database>
</Plugin>
The stackdriver-agent logs confirm that the plugin is loaded and that the plugin
is able to connect to the PostgreSQL server.
collectd[30418]: plugin_load: plugin "postgresql" successfully loaded.
collectd[13849]: Successfully connected to database THE_DATABASE (user THE_USER) at server localhost:5432 (server version: 9.4.12, protocol version: 3, pid: 13862)
By this time, I would expect to see my "log_delay" metric to show up in
Stackdriver monitoring when looking at metrics for the "Instance (GCE)"
resource. I can see that other PostgreSQL metrics have made it through, more
specifically:
I also can't seem to find any of the other default Query [...] metrics
inherited from the default PostgreSQL collectd configuration
referenced by Stackdriver PostgreSQL Plugin Documentation:
# [...]
LoadPlugin postgresql
<Plugin "postgresql">
# [...]
<Database "DATABASE_NAME">
# [...]
User "STATS_USER"
Password "STATS_PASS"
Query backends
Query transactions
Query queries
Query table_states
Query disk_io
Query disk_usage
</Database>
</Plugin>
Question
How do I get my collecd custom replication_lag_seconds metric to show up in Stackdriver Monitoring?
Do I need to configure Custom
Metrics in order to get
the metrics to show up in Stackdriver Monitoring?

The Stackdriver monitoring agent sends a set of curated metrics for each supported third-party application. That set cannot be extended by users -- anything that isn't a curated metric will be ignored by the API and must be sent via the custom metrics mechanism.

Related

Can I use Kusto.Explorer to KQL query an Application Insight instance? [duplicate]

Update July 13, 2021
The links used below are now partially obsolete. Here is the new section on language differences.
Original post
On Azure Portal, in my App Insights / Logs view, I can query the app data like this:
app('my-app-name').traces
The app function is described in the article app() expression in Azure Monitor query.
Kusto.Explorer doesn't understand the app() function, which appears to be explained by the fact it is one of the Additional operators in Azure Monitor.
How can I query my App Insights / Logs with Kusto.Explorer? I cannot use cluster as it is one of the functions not supported in Azure Monitor.
Relevant doc: Azure Monitor log query language differences
Note on troubleshooting joins
(added December 16, 2021)
Pro-tip from Kusto team:
If you are querying application insights from Kusto.Explorer, and your joins to normal clusters fail with bad gateway or other unexpected error, consider adding hint.remote=left to your join. Like:
tableFromApplicationInsights
| join kind=innerunique hint.remote=left tableFromNormalKustoCluster
We have a private preview for Azure Data Explorer (ADX) Proxy that enables you to treat Log Analytics / Application Insights as a virtual cluster, query it using ADX tools and connecting to it as a second cluster in cross cluster query. Since its a private preview you need to contact adxproxy#microsoft.com in order to get enrolled. The proxy is documented at https://learn.microsoft.com/en-us/azure/data-explorer/query-monitor-data.
(disclaimer - I'm the PM driving this project).
Step 1 Connection String
Build your connection string from this template:
https://ade.applicationinsights.io/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.insights/components/<ai-app-name>
Fill in the subscription-id, resource-group-name, and ai-app-name from the portal. Here is an example image
Step 2 Add the connection to Kusto.Explorer
Open Kusto.Explorer, choose Add Connection, and paste your connection string into the Cluster connection field.
After you kit OK, Windows will prompt you to log in with your Azure Active Directory account. Once you have authenticated, Kusto.Explorer will display the Application Insights tables in the Connections panel.

While configuring BPS DB in wso2 is 5.9.0 , which scripts do i have to import in MySQL?

I am following this document-https://is.docs.wso2.com/en/5.9.0/setup/changing-datasource-bpsds/
deployment.toml Configurations.
[bps_database.config]
url = "jdbc:mysql://localhost:3306/IAMtest?useSSL=false"
username = "root"
password = "root"
driver = "com.mysql.jdbc.Driver"
Executing database scripts.
Navigate to <IS-HOME>/dbscripts. Execute the scripts in the following files, against the database created.
<IS-HOME>/dbscripts/bps/bpel/create/mysql.sql
<IS-HOME>/dbscripts/bps/bpel/drop/mysql-drop.sql
<IS-HOME>/dbscripts/bps/bpel/truncate/mysql-truncate.sql
Now create/mysql.sql creates table and the rest two file are responsible for deleting and trucating the same table..............what do i do?????????
Can anyone also tell the use case of BPS datasource??????
Please Help...........
You should only change your bps database if you have a requirement of using the workflow feature[1] in the wso2 identity server. It is mentioned in this documentation https://is.docs.wso2.com/en/5.9.0/setup/changing-to-mysql/
The document supposed to menstion the related db script. But it seems like mis leading. As it has requested to execute all three scripts. if you are using the workflow feature just use the
/dbscripts/bps/bpel/create/mysql.sql
script to create tables in you mysql database.
[1]. https://is.docs.wso2.com/en/5.9.0/learn/workflow-management/

Apache sentry - Get sentry groups to which a given database/tables has been assigned to

I want get for a given database/table the list of groups this database/table has been granted access in sentry.
There does not appear to be a Sentry SHOW command for this purpose in the documentation.
This blog post suggests that you can instead query the Sentry database directly (assuming you are using the Sentry service, not policy files).
However, at present there is no command to show the group to role
mapping. The only way to do this is by connecting to the Sentry
database and deriving this information from the tables in the
database.
If you're using CDH you can determine which node in the cluster is
running the Sentry database using Cloudera Manager, navigating to
Clusters > Sentry, then clicking Sentry Server and then
Configuration. Here you will find the type of database being used
(e.g. MySQL, PostgreSQL, Oracle), the server the databases is running
on, it's port, the database name and user.
You will need the Sentry database password - the blog post gives a suggestion for retrieving it if you do not know it.
An example query for a PostgreSQL database is given:
SELECT "SENTRY_ROLE"."ROLE_NAME","SENTRY_GROUP"."GROUP_NAME"
FROM "SENTRY_ROLE_GROUP_MAP"
JOIN "SENTRY_ROLE" ON "SENTRY_ROLE"."ROLE_ID"="SENTRY_ROLE_GROUP_MAP"."ROLE_ID"
JOIN "SENTRY_GROUP" ON "SENTRY_GROUP"."GROUP_ID"="SENTRY_ROLE_GROUP_MAP"."GROUP_ID";
However, I have not tried this query myself.
This should work for MySQL:
SELECT R.ROLE_NAME, G.GROUP_NAME
FROM SENTRY_ROLE_GROUP_MAP RGM
JOIN SENTRY_ROLE R ON R.ROLE_ID=RGM.ROLE_ID
JOIN SENTRY_GROUP G ON G.GROUP_ID=RGM.GROUP_ID;

boxfuse dev db not provisioned correctly

I'm just starting with boxfuse and can't seem to find a way to get my dev database to be provisioned.
In my boxfuse.yml I have (for the database section):
database:
# the name of your JDBC driver
driverClass: com.mysql.jdbc.Driver
# the username
user: root
# the password
password: <password>
# the JDBC URL
url: jdbc:mysql://10.0.0.84:3306/dmsdb
# any properties specific to your JDBC driver:
properties:
charSet: UTF-8
hibernate.dialect: org.hibernate.dialect.MySQLInnoDBDialect
# the maximum amount of time to wait on an empty pool before throwing an exception
maxWaitForConnection: 1s
# the SQL query to run when validating a connection's liveness
validationQuery: "/* MyApplication Health Check */ SELECT 1"
# the minimum number of connections to keep open
minSize: 8
# the maximum number of connections to keep open
maxSize: 32
# whether or not idle connections should be validated
checkConnectionWhileIdle: false
If I try running it (boxfuse run), my application doesn't work at all.
boxfuse info produces the following:
oxfuse client v.1.18.7.938
Copyright 2016 Boxfuse GmbH. All rights reserved.
Account: mlr11 (mlr11)
Info about mlr11/dms-service in the dev environment:
App Type : Single Instance with Zero Downtime updates
App URL : http://127.0.0.1:8082
DB Type : MySQL database
DB URL : jdbc:mysql://localhost:3306/boxfuse-dev-db
DB Host : localhost
DB Port : 3306
DB Database : boxfuse-dev-db
DB User : boxfuse-dev-db
DB Password : boxfuse-dev-db
DB Status : available
Which is very different than what I was expecting. URL, Database, User, Password) are not matching my boxfuse.yml file.
What I am missing. I know it must be something simple. I did all kind of search and read the doc a few times. I can't seem to find what's wrong. Any pointers will be appreciated.
From the config file you posted I am assuming this is a dropwizard app.
Since your Boxfuse app was configured to use a MySQL database, Boxfuse automatically provisions a database in each environment when you first deploy your application there. In your case you can see the connection info for that database in the dev environment in the output you post in your question.
Boxfuse exposes these values (db url, user, password, ...) as environment variables (https://cloudcaptain.sh/docs/databases#envvars) and automatically configures your framework (Dropwizard I assume) to use those instead of the ones included in your config file. It will do so by passing -Ddw.database.url=$BOXFUSE_DATABASE_URL -Ddw.database.user=$BOXFUSE_DATABASE_USER -Ddw.database.password=$BOXFUSE_DATABASE_PASSWORD as arguments to the JVM.
Also doublecheck in the VirtualBox GUI that your VirtualBox installation is fully functional and able to start VMs and that both the Boxfuse Dev VM and the instance of your application are started properly.

Specify port number and content database for a query in marklogic

I am writing few test cases in test server 8062, but my data resides on port number 8060 with a specific content database.Without changing the content db of test server using the admin console, is it possible to specify which port and content db to hit for a specific query? Also I do not want to load the contents of content db to test server db.
For e.g. something like:
let $current := (fn:count(cts:uri-match("*.xml*")),(),
<options xmlns="xdmp:eval">
<database>{xdmp:database("prj-content")}</database>
</options>)
In MarkLogic the data doesn't "reside" on a port. Rather an app server that's connected to a database listens on a port for HTTP or XDBC requests. You can have many app servers fronting the same database. Testing and administration are two good use cases for more than one app server configured for a database.
Your test server (port 8062) should specify your prj-content database. What is its current database configuration? Why is that different than prj-content. If you do that, you won't have to specify the database at runtime.
If you really do need to specify the database at runtime you can use xdmp:eval, xdmp:invoke, or xdmp:invoke-function.

Resources