Tag: Redgate

  • Vibe Coding a Login Tracking System

    A customer was asking about tracking logins and logouts in Redgate Monitor. We don’t do this natively, as this really needs an XEvent session. I decided to see if an AI could help me get a solution setup that might let me build a custom metric to track this.

    I could do this myself, but it’s some looking syntax and capabilities, futzing with different code items, and trying to think about options. The goal here is can an AI help and save time. Not do the work for me, but assist.

    So maybe not Vibe coding per se, but felt like I did little.

    Video Walkthrough at the bottom.

    This is part of a series of experiments with AI systems.

    Note: This isn’t something I necessarily worry about. The rate might tell me if I’m under attack, but I’d hope applications would detect this first (and be able to block things)

    The Problem

    The customer just asked if they could track logins and logouts. I mentioned the Server Properties (shown below), to see what they’d done. They hadn’t used this, but also, it’s not very flexible or reportable as it puts info in the error log.

    2025-12_0171

    Tracking this info really requires an XE (Extended Events) session. That’s a lightweight way to capture this information. If I want to capture some info about the client logging in, or failing to log in, that’s the way.

    A separate request was could we also get logouts. The only way to do this is with an XE session and the sqlserver.logout event.

    With that in mind, let’s see how my assistant can help.

    Using Claude

    I opened Claude and asked this: “in sql server can I track login counts and logout counts from t-sql?” and actually spelled everything correctly. No savings here.

    The base answer I got started like this, giving me a few options.

    2025-12_0172

    The ending asked me if I’d like to get the Extended Event option. It had provided only the login trigger option. I need an assistant, so I said yes.

    2025-12_0173

    That first answer was maybe 20-30 sec, but I started reading things, so this felt like a discussion with another DBA. Once this started, I let it go and it started to write out and work on code on the right, and then fill in the results on the left.  This was a few minutes, so I flipped over to answer a few emails while I saw this on another monitor.

    The results started with a table to store data and then an XE session. The whole page looks like this, which is a lot.

    2025-12_0175

    Here’s the full left side. Notice that it asks me for a next step. I’ve met a lot of junior DBAs, or even Senior-DBAs-with-1-year-of-experience-10-times that didn’t do this.

    2025-12_0177

    The actual code doesn’t matter yet, since I realized this isn’t getting failed logins. I asked another question and got a response. A polite Claude complements me and then rewrites code. This took another few minutes, and it was neat to see it rewriting its code on the right, adding in a new field in the table and adjusting the session.

    I watched a bit, but got distracted with a Slack message. One nice thing is I can move on to another task while my assistant keeps working.

    2025-12_0178

    At the bottom, I liked the summary of how it works.

    2025-12_0179

    My Slack message was from an AE, asking a question about the server property stuff (from the customer). I could have typed a bunch, but when I looked back, Claude was finished, so I asked it.

    2025-12_0180

    I copy/pasted this to the AE, as it’s a good summary for the customer. This assistant is making my job easier.

    Testing the Solution

    I didn’t just send this. Instead I decided to test this on a few local systems. I keep a DBA database on each instance, so I ran the code in there to create the table and session. As a precaution, since this isn’t my code, I ran each item separately.

    2025-12_0181

    The table worked here. I had another window for the session, which I looked over, but didn’t extensively check. I’m not an XE expert, and I’d likely fumble this code worse than an AI at first, so I checked the events and actions. I decided to just run this since it looked good.

    When it came to the procedure, I got an error. I copied and pasted this into Claude. It recognized an issue and fixed it. This took a few minutes, but this is faster than I could have corrected my own amateurly written query against XE.

    2025-12_0182

    Now I had a procedure. One thing I edited in both the session and proc is that I removed the hard coded c:\SQLData path. I wanted this captured with my other instance stuff in the \logs folder, so I left just the name of the XE session.

    Adding Archival

    One of the things that Redgate Monitor does really well is manage older data. I’ve seen so many people, including myself, set up something like this and then a year later realize they’ve captured GB of data.

    I asked Claude to just fix this for me.

    2025-12_0183

    I grabbed the second command for my Agent Job and changed 180 to 90.

    SQL Agent Job

    Claude again asked me above about jobs, but jobs are simple and easy, and I wanted to think about it for a minute. I right clicked and created a new job. I thought about the name and description I wanted. Then I made two steps, pasting in two exec proc commands for the procs my assistant had written.

    The last thing was some testing. I ran my job to be sure it was working. It completed, which was good.

    I made a few logins and logouts, including a few failed logins. Then I queried my table. I didn’t remember the name, but my assistant tends to pick plain/boring names. So I used SQL Prompt to find it with a ssf <tab> l and got this:

    2025-12_0184

    When I got a query and checked, I see logs of my logins and logouts.

    2025-12_0185

    Redgate Monitor Custom Metric

    My AE and customer wanted to see this in Redgate Monitor, so I decided to ask Claude. It was happy to help.

    2025-12_0186

    I could repeat that for the other items (failed logins and logouts). I didn’t, but this gets me ready to add this to Redgate Monitor.

    Summary

    This shows how an AI assistant can help me set up some auditing for security purposes. There is nothing complex here, and I’ve set up a bunch of this myself in the past. I even have a blog on this.

    However, the code is cumbersome and slow to write for me. Or most humans unless you end up working with XE every day. Even if you use SSMS and the GUI to generate the script, it can be slow. I know I’d certainly have to look things up. In less than 15 minutes, I had a fairly well working solution, with archiving (deleting) old data and I didn’t need to focus tightly the entire time or type a lot. I did some other work, and I could focus on just testing.

    Claude was a great AI assistant to this problem, which is similar to a lot of DBA-type work I’ve done in the past.

    These were the tools I used:

    And, of course, Management Studio 22.

    Addendum

    I tried Google Gemini and ChatGPT. A quick summary of those, which didn’t work as well. At least not to me.

    Note that I use the free versions for all of these tools right now.

    Gemini

    The first prompt got me just a table and trigger, with a followup if I wanted more. I asked about XE and got a basic session, not as easy to read as Claude and embedded inside the response. It also had fewer actions.

    2025-12_0188

    I got to the same place, but it was more prompts and I had to keep guiding it along, like micro, or at least mini, managing another DBA. On the plus side, this was faster.

    ChatGPT

    ChatGPT suggested a trigger, but noted this wasn’t great. It did suggest extended events, and a complete solution. I could have just entered “yes”, but I didn’t. I’m still working on muscle memory at times.

    2025-12_0189

    I got each part of the solution separate, but this has me scrolling through explanation and code. Again, I prefer the Claude side-by-side approach, but this works. And it’s fast.

    2025-12_0190

    This also kept leading me along the process, which I liked. It certainly likes the checkboxes and Xs in its results.

    Both tools helped me with custom metrics.

    Video Walkthrough

    Here is a a retry, and then showing the first solution. I think Claude learned a bit the second time.

  • Monday Monitor Tips: Native Replication Monitoring

    Redgate Monitor has been able to monitor replication for a long term, but it required some work from customers. Now we’ve added native monitoring.

    This is part of a series of posts on Redgate Monitor. Click to see the other posts.

    New Native Monitoring

    The monitoring capabilities in Redgate Monitor were originally fairly limited to a few counters from PerfMon. A few people had written custom metrics on sqlmonitormetrics.com that clients could use, but we’ve had customers asking for more native integrations.

    We’ve done it. With version 14.2, we have added an estate view of your replication environment. In the Estate menu, there is a new entry for Replication Monitoring.

    2025-11_line0125

    If I click this, I get a list of the jobs running replication across various servers. You can see this below, with each instance and the job denoted by a REPL- at the start. These are the defaults that Microsoft sets up and should be left alone.

    You can see below that the agent server name is listed, and I can click it to get to that server overview in Redgate Monitor. I also have the category and job name to the side. Beyond that we have the last completed run if it’s successful. If it’s running, the Job Ended is blank. To the right we have the publisher, subscriber, and distributor names.

    2025-12_0164

    I can resort the columns, such as below when I am looking by category.

    2025-12_0165

    I can also sort by publisher:

    2025-12_0166

    Or subscriber (or any other column).

    2025-12_0167

    Clicking the column a second time reverses the sort order.

    Alerting

    There are two new replication specific alerts available for the job failures and maintenance job failures. These work the same as any other alert in Redgate Monitor and can be configured for specific servers, groups, levels, etc., with notifications going out to all the notification targets.

    Here are the alerts in the alert configuration.

    2025-12_0168

    These jobs run across the various replication categories: distribution, merge, snapshot, log reader, and queue reader.

    If I look at the details, I can see the job failure works across multiple categories and is set to a high level alert. I can adjust this as I can with any other Redgate Monitor alerts, and exclude jobs if I wish with a regular expression.

    2025-12_0169

    The replication capabilities are documented here: https://documentation.red-gate.com/monitor14/sql-server-replication-314869637.html

    Summary

    Replication isn’t something most people use, but for those that do implement it, monitoring is critical. Redgate Monitor has added some native capabilities to let you get a glimpse of your entire replication estate at once and get notified if there are issues.

    Replication can be amazing, but I find it brittle. When it works, it’s amazing, but when it breaks, it’s broken. Getting a jump on issues is important for many organizations and Redgate Monitor can help you do that.

    Redgate Monitor is a world class monitoring solution for your database estate. Download a trial today and see how it can help you manage your estate more efficiently.

  • Flyway Tips: Automation Assistance in Flyway Desktop

    I was chatting with the product managers at Flyway and one asked me whether I’d seen the new tab for Automation in Flyway Desktop. I hadn’t and decided to take a quick look at how this works and what’s useful. This post looks at the new feature.

    Tl;Dr this is a good way to start learning how to move to a more DevOps, automated way of deploying changes.

    I’ve been working with Flyway and Flyway Desktop for work more and more as we transition from older SSMS plugins to the standalone tool. This series looks at some tips I’ve gotten along the way.

    Working with Flyway Desktop

    For a lot of customers, it’s not too hard to setup a project and start to capture code in a Git repo. However, adding in automation gets challenging for many, especially as the docs are hard to understand if you don’t already have some knowledge. I find that CI/CD is a bit of a chicken and egg challenge as we try to learn to get better, but knowing what to learn and do requires knowledge.

    Which we don’t have.

    In any case, I’ve taken an existing Flyway project where I am capturing some code. You can see the project below, with objects on the right. The database and the repo have the same object code and are in sync.

    2025-11_line0127

    Let’s add a few new objects to this database in SSMS. You can see below I’m adding a new table and altering a proc. I’m also refactoring slightly to not keep the old style join convention in my proc as I add a new join.

    2025-11_line0129

    Once I do this, in Flyway Desktop (FWD), I see my changes. I’ll save these to the repo and then generate a migration script. I won’t show that as it’s not important.

    2025-11_line0130

    Once I’ve done this, I know I want to deploy code. If I go to Migrations, I can see I have these two scripts ready to go to QA, and I can deploy them with FWD manually. However, I don’t want to do that.

    2025-11_line0131

    I want some automation. How does FWD make that easy? Let’s see.

    The Automation Tab

    There’s a new tab on the left, which is the Automation tab.  I’ve expanded the left menu out and you can see it, but it’s a lightning bolt, which I might never have noticed (hence this post).

    2025-11_line0132

    If I click this, I get a little explanation at the top, a few links, and then some CLI based code. This last part is the important part of what I need to move to CI/CD.

    2025-11_line0133

    If you look at the code closely, you’ll see some placeholders in angle brackets for the environments I need. The code looks like this:

    2025-11_line0134

    Above this, there are two drop downs where I can select my build and target environments. Build is the CI portion, and it’s a good idea to have a place to build code separate from QA. This lets me validate things, and more importantly, run some code analysis checks, summarize changes, and detect drift.

    I’ve expanded the Build drop down below and you can see I have my environments listed, and I can also manage them from here. There is also an Environments tab on the left menu just above Automate Deployments that looks like a database icon.

    2025-11_line0135

    Once I select an environment, the code changes to reflect this. That makes things easier to automate as I can take these commands and drop them into a task in my CI/CD tool.Note in the image below that I’ve selected NWInt and the code shows target2. The code needs the ID (or PK) of the environment, but the display name I entered is shown in the drop down. Trust me, these match.

    2025-11_line0136

    I’ll also select a target and then open up a CLI to run the first item on line 5. I did have to auth, but this runs successfully. No doc checks, no experimenting, the command ran.

    2025-12_0116

    I’ve never saved any snapshots and so the drift doesn’t work right away, but I’ll get the dryrun script. When I run this, I get a summary from the CLI.

    2025-12_0120

    Then I can see the report (see above output for the path at the end. When this opens, on the Dry Run tab, I see my scripts.

    2025-12_0121

    Note, I did use the drop downs in FWD to select the environments I need for this.

    Very cool.

    Summary

    One of the challenges with using Flyway is that there are a lot of settings, options, and more that one must learn to take advantage of the solution. Our docs continue to improve, but even for someone that has been using Flyway for a few years, I have to constantly check out things work. Plus, the teams are adding features on a regular basis, so it can get confusing to learn the new things.

    This automation tab is really helpful to shortcut some of the things I need for the various environments in my project. I’m going to start using some of this in a new project, and so should you.

    Flyway can do much more, and for smoother automation, check out Flyway Enterprise.

    Flyway is an incredible way of deploying changes from one database to another, and now includes both migration-based and state-based deployments. You get the flexibility you need to control database changes in your environment. If you’ve never used it, give it a try today. It works for SQL Server, Oracle, PostgreSQL and nearly 50 other platforms.

    Video Walkthrough

     

  • The Book of Redgate: What Our Staff Says

    This image is from 2010, and it goes along with my last post of what our Customers Say about us. However, this is what our employees said about the company.

    2025-10_line0105

    At this point we would have been around a 200 person company, mostly in the UK. It’s a great list of words, and if I were looking for a new employer, this type of work cloud might get me interested in applying.

    Redgate has often felt like an extended family, where we care about each other, we’re bonded, and we’re working together to get through life. We disagree and bicker at times, but we love each other.

    We’re now closer to a 600 person company, and I don’t know that all of us, or even most of us, feel the same ways, but I’d like to think most people still think this is a great place to work.

    I do.

    I have a copy of the Book of Redgate from 2010. This was a book we produced internally about the company after 10 years in existence. At that time, I’d been there for about 3 years, and it was interesting to learn a some things about the company. This series of posts looks back at the Book of Redgate 15 years later.